void pipe() { if (createFile("\\\\.\\pipe\\cuckoo") != INVALID_HANDLE_VALUE) { createAndWriteFile("pipe.txt"); printf("Cuckoo Detected (\\\\.\\pipe\\cuckoo)\n"); } }
void ProjectManagerWindow::onCreateClicked() { if (!(m_nameLine->text().isEmpty()) && !(m_pathLine->text().isEmpty())) { QString fileExtension = m_extension[m_listWidget->currentItem()]; if (fileExtension == ".robopro") { emit createProject(m_nameLine->text(), m_pathLine->text()); emit createFile("main.cpp", m_pathLine->text()); emit projectCreated(); } else { emit createFile(m_nameLine->text() + fileExtension, m_pathLine->text()); } m_nameLine->setText("undefined"); this->close(); } }
QString Install::createScriptSetIptablesKernelDefaults() { QStringList script; QString filename = "qiptables-restore-kernel-setting-defaults.sh"; script << "#!/bin/bash" << "" << GenLib::getGnuLicence().join("\n") << "" << "################################################" << "#" << QString("# ").append(filename) << "#" << "# created by qiptables install program" << "#" << "#" << "################################################" << "" << "" << "echo \"Restoring iptables kernel setting defaults...\"" << "" << "echo \"Enable broadcast echo Protection\" " << "echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts" << "" << "echo \"Disable Source Routed Packets\" " << "echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route" << "" << "echo \"Enable TCP SYN Cookie Protection\" " << "echo 1 > /proc/sys/net/ipv4/tcp_syncookies" << "" << "echo \"Disable ICMP Redirect Acceptance\" " << "echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects" << "" << "echo \"Don't send Redirect Messages\" " << "echo 0 > /proc/sys/net/ipv4/conf/default/send_redirects" << "" << "echo \"Drop Spoofed Packets coming in on an interface where responses\" " << "echo \"would result in the reply going out a different interface.\" " << "echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter" << "" << " " << " "; // Create the file filename = createFile(Install::TOOLS_DIR, filename, script, true); QString tmpSnippetName = "Restore iptables kernel settings defaults"; QStringList snippetList; snippetList << QString("# %1").arg(tmpSnippetName) << filename << ""; insertRuleSnippetRow(tmpSnippetName, snippetList); return filename; }
/* ** Sync the file. */ static int jrnlSync(sqlite3_file *pJfd, int flags){ int rc; JournalFile *p = (JournalFile *)pJfd; rc = createFile(p); if( rc==SQLITE_OK ){ rc = sqlite3OsSync(p->pReal, flags); } return rc; }
void CFileLog::checkFile() { if (nums >= 100000) { fclose(fp); createFile(); nums = 0; } }
void SHA256TestSuite::someFiles() { createFile("empty.txt", ""); CPPUNIT_ASSERT(SHA256::hashFile("empty.txt") == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); createFile("superSecretPassword.txt", "passw0rd"); CPPUNIT_ASSERT(SHA256::hashFile("superSecretPassword.txt") == "8f0e2f76e22b43e2855189877e7dc1e1e7d98c226c95db247cd1d547928334a9"); createFile("fileWithEmbeddedZeros.txt", // 1 2 // 12345 678901 234567890 1234 std::string("some\0zeros\0embedded\0here", 24)); CPPUNIT_ASSERT(SHA256::hashFile("fileWithEmbeddedZeros.txt") == "ce2755ad80159b7a2ab0adfc0246678239e583f83dbf423b8a48d6c8aedd2cb7"); }
//main () int main (int argc, char *argv[]) { //Call syntax check if (argc != 3) { printf ("Usage: %s Title_list_filename Sequence_list_filename\n", argv[0]); exit (1); } //Main variables string title, sequence; FILE *titleInFile = NULL, *sequenceInFile = NULL, *outFile = NULL; int count = 0; //File creation and checks printf ("Opening files..\n"); createFile (&titleInFile, argv[1], 'r'); createFile (&sequenceInFile, argv[2], 'r'); createFile (&outFile, "Combined.fasta", 'w'); //Combine entries printf ("File opened. Combining...\n"); initializeString (&title); initializeString (&sequence); while (1) { //Load the data, break the loop if either list runs out loadString (&title, titleInFile); loadString (&sequence, sequenceInFile); if ((title.str == NULL) || (sequence.str == NULL)) { break; } //Print the new fasta entry and reset for the next set fprintf (outFile, ">%s\n%s\n", title.str, sequence.str); reinitializeString (&title); reinitializeString (&sequence); //A counter so the user has some idea of how long it will take if (++count % 1000000 == 0) { printf ("%d entries combined...\n", count); } } //Close everything and free memory printf ("%d entries combined. Closing files and freeing memory...\n", count); free (title.str); free (sequence.str); fclose (titleInFile); fclose (sequenceInFile); fclose (outFile); return 0; }
int createTrackFromUri( char *uri , char *name ) { TRACE_2( PLAYERMANAGER , "createTrackFromUri( %s , __track__ )" , uri ); sp_link *link; sp_error error; if( playing == FALSE && hasNextTrack() == FALSE ) createFile( name ); TRACE_1( PLAYERMANAGER , "Creating URI : %s" , uri ); link = sp_link_create_from_string( uri ); if( link == NULL ) { TRACE_ERROR( PLAYERMANAGER , "Fail to create link."); return PC_ERROR; } else { TRACE_1( PLAYERMANAGER , "Success to create link."); } TRACE_3( PLAYERMANAGER , "Construct track..."); currentTrack = sp_link_as_track( link ); if( currentTrack == NULL ) { TRACE_ERROR( PLAYERMANAGER , "Fail to create track."); return PC_ERROR; } else { TRACE_1( PLAYERMANAGER , "Success to create track."); } error = sp_track_add_ref( currentTrack ); if( error != SP_ERROR_OK ) { TRACE_ERROR( PLAYERMANAGER , "Cannot add ref track, reason: %s" , sp_error_message( error ) ); return PC_ERROR; } sp_link_release( link ); running = TRUE; // playing = FALSE; return PC_SUCCESS; }
void GTest_uHMMERBuild::init(XMLTestFormat* tf, const QDomElement& el) { Q_UNUSED(tf); QString inFile = el.attribute(IN_FILE_NAME_ATTR); if (inFile.isEmpty()) { failMissingValue(IN_FILE_NAME_ATTR); return; } outFile = el.attribute(OUT_FILE_NAME_ATTR); if (outFile.isEmpty()) { failMissingValue(OUT_FILE_NAME_ATTR); return; } QString expOpt = el.attribute(EXP_OPT_ATTR); if (expOpt.isEmpty()) { failMissingValue(EXP_OPT_ATTR); return; } QString hmmName = el.attribute(HMM_NAME_ATTR); QString delTempStr = el.attribute(DEL_TEMP_FILE_ATTR); if (delTempStr .isEmpty()) { failMissingValue(DEL_TEMP_FILE_ATTR); return; } if(delTempStr=="yes") deleteTempFile = true; else if(delTempStr=="no") deleteTempFile =false; else { failMissingValue(DEL_TEMP_FILE_ATTR); return; } UHMMBuildSettings s; s.name = hmmName; if(expOpt=="LS") s.strategy = P7_LS_CONFIG; else if(expOpt=="FS") s.strategy = P7_FS_CONFIG; else if(expOpt=="BASE") s.strategy = P7_BASE_CONFIG; else if(expOpt=="SW") s.strategy = P7_SW_CONFIG; else { stateInfo.setError( QString("invalid value %1, available values: LS, FS, BASE, SW").arg(EXP_OPT_ATTR) ); return; } QFileInfo fi(env->getVar("TEMP_DATA_DIR")+"/"+outFile); fi.absoluteDir().mkpath(fi.absoluteDir().absolutePath()); QFile createFile(fi.absoluteFilePath()); createFile.open(QIODevice::WriteOnly); if(!createFile.isOpen()){ stateInfo.setError( QString("File opening error \"%1\", description: ").arg(createFile.fileName())+createFile.errorString() ); return; } else createFile.close(); buildTask = new HMMBuildToFileTask(env->getVar("COMMON_DATA_DIR")+"/"+inFile, createFile.fileName(), s); outFile = createFile.fileName(); addSubTask(buildTask); }
void DumpRenderTree::doneDrt() { fclose(stdout); fclose(stderr); unlink(getPPSPath().c_str()); // Notify the external world that we're done. createFile(m_doneFile); (m_page->client())->notifyRunLayoutTestsFinished(); }
void TraceLog::logNewSectionCalled(const ADDRINT prevAddr, std::string prevSection, std::string currSection) { createFile(); m_traceFile << std::hex << prevAddr << DELIMITER << prevSection << "->" << currSection << std::endl; m_traceFile.flush(); }
void TraceLog::logSectionChange(const ADDRINT prevAddr, std::string name) { createFile(); m_traceFile << std::hex << prevAddr << DELIMITER << "section: " << name << std::endl; m_traceFile.flush(); }
TEST_F(FlushRewrittenFilesTest, StoresChangesOnDisk) { FileID ID = createFile("input.cpp", "line1\nline2\nline3\nline4"); Replacements Replaces; Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1), 5, "replaced")); EXPECT_TRUE(applyAllReplacements(Replaces, Context.Rewrite)); EXPECT_FALSE(Context.Rewrite.overwriteChangedFiles()); EXPECT_EQ("line1\nreplaced\nline3\nline4", getFileContentFromDisk("input.cpp")); }
void TestShellBuddy::testDisableBuddies() { /* 3. Deactivate buddy option, Activate open next to active tab Open a.cpp a.l.txt Verify order (a.cpp a.l.txt) Verify that a.l.txt is activated Activate a.cpp Open b.cpp Verify order (a.cpp b.cpp a.l.txt) */ QCOMPARE(m_documentController->openDocuments().count(), 0); enableBuddies(false); enableOpenAfterCurrent(); QTemporaryDir dirA; createFile(dirA, QStringLiteral("a.l.txt")); createFile(dirA, QStringLiteral("a.r.txt")); createFile(dirA, QStringLiteral("b.r.txt")); m_documentController->openDocument(QUrl::fromLocalFile(dirA.path() + "a.r.txt")); m_documentController->openDocument(QUrl::fromLocalFile(dirA.path() + "a.l.txt")); Sublime::Area *area = m_uiController->activeArea(); Sublime::AreaIndex* areaIndex = area->indexOf(m_uiController->activeSublimeWindow()->activeView()); // Buddies disabled => order of tabs should be the order of file opening verifyFilename(areaIndex->views().value(0), "a.r.txt"); verifyFilename(areaIndex->views().value(1), "a.l.txt"); verifyFilename(m_uiController->activeSublimeWindow()->activeView(), "a.l.txt"); //activate a.cpp => new doc should be opened right next to it m_uiController->activeSublimeWindow()->activateView(areaIndex->views().value(0)); m_documentController->openDocument(QUrl::fromLocalFile(dirA.path() + "b.r.txt")); verifyFilename(areaIndex->views().value(0), "a.r.txt"); verifyFilename(areaIndex->views().value(1), "b.r.txt"); verifyFilename(areaIndex->views().value(2), "a.l.txt"); verifyFilename(m_uiController->activeSublimeWindow()->activeView(), "b.r.txt"); QCOMPARE(m_documentController->openDocuments().count(), 3); for(int i = 0; i < 3; i++) m_documentController->openDocuments().at(0)->close(IDocument::Discard); QCOMPARE(m_documentController->openDocuments().count(), 0); }
void ViewFileManager::on(QueueManagerListener::ItemAdded, const QueueItemPtr& aQI) noexcept { if (!isViewedItem(aQI)) { return; } auto file = createFile(aQI->getTarget(), aQI->getTTH(), aQI->isSet(QueueItem::FLAG_TEXT), false); if (file) { file->onAddedQueue(aQI->getTarget(), aQI->getSize()); } }
Generator<Annotation, Runtime, Driver>::Generator( Driver & driver, const std::string & file_name ) : p_driver(driver), p_file_name(file_name), p_file_id(createFile()) { Runtime::useSymbolsKernel(p_driver, p_file_id); }
bool ViewFileManager::addLocalFile(const string& aPath, const TTHValue& aTTH, bool aIsText) noexcept { if (getFile(aTTH)) { return false; } auto file = createFile(aPath, aTTH, aIsText, true); fire(ViewFileManagerListener::FileFinished(), file); return true; }
void LogTraceListener::createFile(const QDateTime& time) { if (time.time().hour() == 0 && time.time().minute() == 0) { _file->close(); delete _file; _file = NULL; createFile(_logPath.c_str()); } }
void TraceLog::logCall(const ADDRINT prevAddr, const ADDRINT callAddr) { createFile(); m_traceFile << std::hex << prevAddr << DELIMITER << "called: ?? [" << callAddr << "]" << std::endl; m_traceFile.flush(); }
void TestShellBuddy::testDisableOpenAfterCurrent() { /* 5. Enable buddy option, Disable open next to active tab Open foo.l.txt bar.cpp foo.cpp Verify order (foo.l.txt foo.cpp bar.cpp) Verify that foo.cpp is activated Open x.cpp => tab must be placed at the end Verify order (foo.l.txt foo.cpp bar.cpp x.cpp) Verify that x.cpp is activated*/ QCOMPARE(m_documentController->openDocuments().count(), 0); enableBuddies(); enableOpenAfterCurrent(false); QTemporaryDir dirA; createFile(dirA, QStringLiteral("foo.l.txt")); createFile(dirA, QStringLiteral("bar.r.txt")); createFile(dirA, QStringLiteral("foo.r.txt")); createFile(dirA, QStringLiteral("x.r.txt")); m_documentController->openDocument(QUrl::fromLocalFile(dirA.path() + "foo.l.txt")); m_documentController->openDocument(QUrl::fromLocalFile(dirA.path() + "bar.r.txt")); m_documentController->openDocument(QUrl::fromLocalFile(dirA.path() + "foo.r.txt")); Sublime::Area *area = m_uiController->activeArea(); Sublime::AreaIndex* areaIndex = area->indexOf(m_uiController->activeSublimeWindow()->activeView()); verifyFilename(areaIndex->views().value(0), "foo.l.txt"); verifyFilename(areaIndex->views().value(1), "foo.r.txt"); verifyFilename(areaIndex->views().value(2), "bar.r.txt"); verifyFilename(m_uiController->activeSublimeWindow()->activeView(), "foo.r.txt"); m_documentController->openDocument(QUrl::fromLocalFile(dirA.path() + "x.r.txt")); verifyFilename(areaIndex->views().value(0), "foo.l.txt"); verifyFilename(areaIndex->views().value(1), "foo.r.txt"); verifyFilename(areaIndex->views().value(2), "bar.r.txt"); verifyFilename(areaIndex->views().value(3), "x.r.txt"); verifyFilename(m_uiController->activeSublimeWindow()->activeView(), "x.r.txt"); QCOMPARE(m_documentController->openDocuments().count(), 4); for(int i = 0; i < 4; i++) m_documentController->openDocuments().at(0)->close(IDocument::Discard); QCOMPARE(m_documentController->openDocuments().count(), 0); }
/* * Class: edu_uw_apl_commons_tsk4j_filesys_FileSystem * Method: dirOpen * Signature: (JLjava/lang/String;)Ledu/uw/apl/commons/tsk4j/filesys/Directory; */ JNIEXPORT jobject JNICALL Java_edu_uw_apl_commons_tsk4j_filesys_FileSystem_dirOpen (JNIEnv *env, jobject thiz, jlong nativePtr, jstring path ) { const char* pathC = (*env)->GetStringUTFChars( env, path, NULL ); TSK_FS_INFO* info = (TSK_FS_INFO*)nativePtr; TSK_FS_DIR* fsDir = tsk_fs_dir_open( info, pathC ); if( !fsDir ) { (*env)->ReleaseStringUTFChars( env, path, pathC ); return (jobject)NULL; } TSK_FS_FILE* fsFile = fsDir->fs_file; jobject fileMeta = NULL; if( fsFile->meta ) { fileMeta = createFileMeta( env, fsFile->meta ); if( !fileMeta ) { tsk_fs_dir_close( fsDir ); (*env)->ReleaseStringUTFChars( env, path, pathC ); return NULL; } } jobject fileName = NULL; if( fsFile->name ) { fileName = createFileName( env, fsFile->name ); if( !fileName ) { tsk_fs_dir_close( fsDir ); (*env)->ReleaseStringUTFChars( env, path, pathC ); // LOOK: release fileMeta ???? return NULL; } } jobject file = createFile( env, fsFile, thiz, fileMeta, fileName ); if( !file ) { tsk_fs_dir_close( fsDir ); (*env)->ReleaseStringUTFChars( env, path, pathC ); // LOOK: release fileMeta, fileName ???? return NULL; } jobject result = createDirectory( env, fsDir, thiz, file ); if( !result ) { tsk_fs_dir_close( fsDir ); (*env)->ReleaseStringUTFChars( env, path, pathC ); // LOOK: release fileMeta, fileName, file ???? return NULL; } (*env)->ReleaseStringUTFChars( env, path, pathC ); return result; }
int main(int argc, char *argv[]) { if ( argc != 2 ) { /* display usage on error stream */ fprintf(stderr, "usage: znm-project project_name\n\n"); exit(1); /* exit status of the program : non-zero for errors */ } if ( QString("--help") == argv[1] ) { printf ("usage: znm-project project_name\nCreates a zenom project.\n\n"); exit(0); /* exit status of the program : non-zero for errors */ } QDir projectDir; if ( projectDir.exists( argv[1] ) ) { fprintf(stderr, "The project cannot be created because '%s' folder already exists.\n", argv[1]); exit(1); /* exit status of the program : non-zero for errors */ } projectDir.mkpath( argv[1] ); projectDir.cd( argv[1] ); QFileInfo programFileInfo( getexepath() ); QString projectName( QFileInfo(argv[1]).fileName() ); createFile( programFileInfo.dir().filePath("znm-project-main.template"), projectDir.filePath("main.cpp"), projectName ); createFile( programFileInfo.dir().filePath("znm-project-makefile.template"), projectDir.filePath("Makefile"), projectName ); // Open project file to write QFile configFile( projectDir.filePath(QString("%1.znm").arg(projectName)) ); if ( !configFile.open(QFile::WriteOnly | QFile::Text) ) { fprintf(stderr, "The project cannot be created because the file '%s' could not be opened.\n", configFile.fileName().toAscii().data()); exit(1); /* exit status of the program : non-zero for errors */ } configFile.close(); return 0; }
void initSysop(void) { long tid; createDirOrDie("NiKom:Users"); createDirOrDie("NiKom:Users/0"); createDirOrDie("NiKom:Users/0/0"); time(&tid); userData.forst_in=tid; userData.senast_in=tid; createFile("NiKom:Users/0/0/Data", &userData, sizeof(struct User)); unreadTexts.bitmapStartText = 0; memset(unreadTexts.bitmap, 0xff, UNREADTEXTS_BITMAPSIZE/8); memset(unreadTexts.lowestPossibleUnreadText, 0, MAXMOTE * sizeof(long)); createFile("NiKom:Users/0/0/UnreadTexts", &unreadTexts, sizeof(struct UnreadTexts)); createFile("Nikom:Users/0/0/.firstletter", "0", 1); createFile("Nikom:Users/0/0/.nextletter", "0", 1); }
void test_createCloseUnlink(){ char* filename = "AAUnlinkZ.txt"; int fdCreate = createFile(filename); close(fdCreate); int unlinkSuccess = unlink(filename); if (unlinkSuccess == 0){ printf("-------test_createCloseUnlink TEST PASSED-------\n"); } else { printf("-------test_createCloseUnlink TEST FAILED-------\n"); } }
//main () int main (int argc, char *argv[]) { //Call syntax check if (argc != 6) { printf ("Usage: %s Fasta_filename Human_interactions Yeast_interactions Negative_interactions Output_CSV_filename\n", argv[0]); exit (1); } //Main variables fastaEntry *firFasta = NULL; FILE *inFile, *fasFile, *outFile; //File creation and checks printf ("Opening initial files...\n"); createFile (&fasFile, argv[1], 'r'); createFile (&inFile, argv[2], 'r'); createFile (&outFile, argv[5], 'w'); fprintf (outFile, "Source,Protein,A,C,D,E,F,G,H,I,K,L,M,N,P,Q,R,S,T,V,W,Y,Class\n"); //Build dynamic linked list of scaf data printf ("Files found and created. Compiling fasta entries...\n"); createFastaEntry (&firFasta); createFastaList (firFasta, fasFile); fclose (fasFile); //Find the entries from the Human interaction file printf ("Compiled. Cross referencing with Human interaction profile...\n"); crossCheck (firFasta, 'H', 'I', inFile, outFile); fclose (inFile); //Find the entries from the Yeast interaction file printf ("Cross referenced. Cross referencing with Yeast interaction profile...\n"); createFile (&inFile, argv[3], 'r'); crossCheck (firFasta, 'Y', 'I', inFile, outFile); fclose (inFile); //Find the entries from the Negative interaction file printf ("Cross referenced. Cross referencing with Negative interaction profile...\n"); createFile (&inFile, argv[4], 'r'); crossCheck (firFasta, 'N', 'N', inFile, outFile); fclose (inFile); //Close everything printf ("Cross referenced. Freeing memory and closing files...\n"); fclose (outFile); freeFastaList (firFasta); printf ("Done.\n"); return 0; }
AccountsDatabasePtr AccountsDatabase::createDefault(const ServerInstanceDir::GenerationPtr &generation, bool userSwitching, const string &defaultUser, const string &defaultGroup) { AccountsDatabasePtr database(new AccountsDatabase()); struct passwd *defaultUserEntry; struct group *defaultGroupEntry; uid_t defaultUid; gid_t defaultGid; RandomGenerator random; string passengerStatusPassword = random.generateByteString(MESSAGE_SERVER_MAX_PASSWORD_SIZE); defaultUserEntry = getpwnam(defaultUser.c_str()); if (defaultUserEntry == NULL) { throw NonExistentUserException("Default user '" + defaultUser + "' does not exist."); } defaultUid = defaultUserEntry->pw_uid; defaultGroupEntry = getgrnam(defaultGroup.c_str()); if (defaultGroupEntry == NULL) { throw NonExistentGroupException("Default group '" + defaultGroup + "' does not exist."); } defaultGid = defaultGroupEntry->gr_gid; // An account for the 'passenger-status' command. Its password is only readable by // root, or (if user switching is turned off) only by the web server's user. database->add("_passenger-status", passengerStatusPassword, false, Account::INSPECT_BASIC_INFO | Account::INSPECT_SENSITIVE_INFO | Account::INSPECT_BACKTRACES); if (geteuid() == 0 && !userSwitching) { createFile(generation->getPath() + "/passenger-status-password.txt", passengerStatusPassword, S_IRUSR, defaultUid, defaultGid); } else { createFile(generation->getPath() + "/passenger-status-password.txt", passengerStatusPassword, S_IRUSR | S_IWUSR); } return database; }
bool rssconwindowsOpen(Rsscon* rsscon) { bool createFile(const char* device, RssconwindowsPortdata* pdata); bool setCommConfiguration(const char*, RssconwindowsPortdata*, DCB*); bool setCommState(const char*, RssconwindowsPortdata*, DCB*); bool handshakeOff(RssconwindowsPortdata* portdata); bool readTimeoutBlocking(RssconwindowsPortdata* pdata); bool readTimeoutNonblocking(RssconwindowsPortdata* pdata); assert(rsscon != NULL); assert(rsscon->portdata != NULL); RssconwindowsPortdata* pdata = (RssconwindowsPortdata*) rsscon->portdata; LOG4C_CATEGORY log = get_log(LOG_CATEGORY); log_debug(log, "open windows device for rsscon %d.", rsscon); rssconSetLastError(rsscon, RSSCON_ERROR_NOERROR); const char* device = rssconGetDevice(rsscon); log_debug(log, "create file for device %s.", device); if (!createFile(device, pdata)) { rssconSetLastError(rsscon, RSSCON_ERROR_OPENDEVICE); return false; } DCB port = {0}; port.DCBlength = sizeof(DCB); log_debug(log, "set comm configuration for device %s.", device); if (!setCommConfiguration(device, pdata, &port)) { rssconSetLastError(rsscon, RSSCON_ERROR_SETUPDEVICE); return false; } log_debug(log, "set the comm state for the port handler %d.", pdata->portHandle); if (!setCommState(device, pdata, &port)) { rssconSetLastError(rsscon, RSSCON_ERROR_SETUPDEVICE); return false; } log_debug(log, "set the handshake for the port handler %d.", pdata->portHandle); if (!handshakeOff(pdata)) { rssconSetLastError(rsscon, RSSCON_ERROR_SETUPDEVICE); return false; } log_debug(log, "set the timeout blocking for the port handler %d.", pdata->portHandle); if (!readTimeoutBlocking(pdata)) { rssconSetLastError(rsscon, RSSCON_ERROR_SETUPDEVICE); return false; } return true; }
// Test the low level interface int MarketDefaultTest::Tester::testLowLevel() { mStatus.message(kInfoMessage, _T("Starting testLowLevel\r\n")); // If we haven't created the lowlevel test file do so now // We can only create it once for each MAX session, because // we can't delete the MarketDefaults object. if (!file2Initialized) { initFileValues(&file2); TSTR path = getDefaultFilePath(_T("testLowLevelRead.ini")); DeleteFile(path); if (!createFile(path, &file2)) return 1; file2Initialized = true; } // Get the MarketDefaults object MarketDefaults* dflts = GetMarketDefaults(_T("testLowLevelRead")); if (dflts == NULL) { mStatus.message(kErrorMessage, _T("Unexpected Error: Market defaults is NULL\r\n")); return 1; } int errors = 0; // Verify the values in each section and key errors += verifyValues(dflts, &file2); // This one we can do multiple times, because we are using the API initFileValues(&file1); dflts = GetMarketDefaults(_T("testLowLevelWrite")); if (dflts == NULL) { mStatus.message(kErrorMessage, _T("Unexpected Error: Market defaults is NULL\r\n")); return 1; } // Write the value using the API errors += putFile(dflts, &file1); // Verify that they are correct errors += verifyValues(dflts, &file1); // Remove some of the values removeValues(dflts, &file1); // Verify that they are correct errors += verifyValues(dflts, &file1); // Cleanup deleteFileValues(&file1); DeleteFile(GetMarketDefaultsFileName(_T("testLowLevelWrite"))); mStatus.message(kInfoMessage, _T("Finished testLowLevel - %d error(s)\r\n\r\n"), errors); return errors; }
int MarketDefaultTest::Tester::testFilePresent(const TCHAR* file) { mStatus.message(kInfoMessage, _T("Starting testFilePresent %s\r\n"), file); // Now try again with a file that should exist TSTR path = getFactoryDefaultFilePath(file); DeleteFile(path); TSTR expected = getDefaultFilePath(file); DeleteFile(expected); if (!createFile(expected, &file1)) return 1; char* valueSrc; long lengthSrc; int foundSrc = getFileContents(expected, valueSrc, lengthSrc); int errors = 0; // Now copy it to the defaults directory TSTR newPath = GetMarketDefaultsFileName(file); if (newPath != expected) { mStatus.message(kErrorMessage, _T("%s was copied to the wrong file\r\n") _T(" Expected: %s\r\n") _T(" Got: %s\r\n"), path.data(), expected.data(), newPath.data()); ++errors; } char* valueDst; long lengthDst; int foundDst = getFileContents(expected, valueDst, lengthDst); if (!filesAreEqual(foundSrc, valueSrc, lengthSrc, foundDst, valueDst, lengthDst)) { mStatus.message(kErrorMessage, _T("%s was changed by copy\r\n"), expected.data()); ++errors; } // Clean up delete[] valueSrc; delete[] valueDst; DeleteFile(path); DeleteFile(expected); DeleteFile(newPath); mStatus.message(kInfoMessage, _T("Finished testFilePresent %s - %d error(s)\r\n\r\n"), file, errors); return errors; }
/** * Test that a file can be opened */ void test_createOpenTest(){ char* filename = "AAnewFile.txt"; int fdCreate = createFile(filename); int fdOpen = openFile(filename); if (fdCreate != fdOpen){ printf("-------createOpenTest TEST FAILED-------\n The opened file descriptor and the existing file descriptor should match"); } else { printf("-------createOpenTest TEST PASSED-------\n"); close(fdCreate); unlink(filename); } }