// ------------------------------------------------ int main(int argc, char** argv) { int nfiles = 256; // Prepare the data size_t total_bytes_to_read = 0; for( int i=0; i<nfiles; ++i ) { TRequest r; sprintf( r.name, "data/data%03d.bin", i ); r.size = 100 + i * 100; r.contents = i & 255; r.buf = new char[ r.size ]; total_bytes_to_read += r.size; requests.push_back( r ); } // If no arguments are given, create the files if( argc == 1 ) { if( !createFiles( nfiles ) ) return -2; } readAllAsync(); checkFiles(); readAllSync(); checkFiles(); return 0; }
void createNewFile (Project::Item parent) { for (;;) { AlertWindow aw (TRANS ("Create new Component class"), TRANS ("Please enter the name for the new class"), AlertWindow::NoIcon, nullptr); aw.addTextEditor (getClassNameFieldName(), String::empty, String::empty, false); aw.addButton (TRANS ("Create Files"), 1, KeyPress (KeyPress::returnKey)); aw.addButton (TRANS ("Cancel"), 0, KeyPress (KeyPress::escapeKey)); if (aw.runModalLoop() == 0) break; const String className (aw.getTextEditorContents (getClassNameFieldName()).trim()); if (className == CodeHelpers::makeValidIdentifier (className, false, true, false)) { const File newFile (askUserToChooseNewFile (className + ".h", "*.h;*.cpp", parent)); if (newFile != File::nonexistent) createFiles (parent, className, newFile); break; } } }
desc init_env(const char *dir, char *file_path, char *link_path) { desc in_desc = {-1, -1, -1, -1}; if (mkdir(dir, 0777) < 0) { err("error in creating directory: %s, %s", dir, strerror(errno)); return in_desc; } in_desc.inot = inotify_init(); if (in_desc.inot < 0) { err("inotify_init () Failed, %s", strerror(errno)); rmdir(dir); return in_desc; } if (snprintf(file_path, BUF_SIZE, "%s/%s", dir, filename) >= BUF_SIZE) { err("filename %s is too long", filename); rmdir(dir); return in_desc; } if (snprintf(link_path, BUF_SIZE, "%s/%s", dir, linkname) >= BUF_SIZE) { err("filename %s is too long", linkname); rmdir(dir); return in_desc; } in_desc.dir = addWatcher(in_desc.inot, dir); if (createFiles(file_path, filename, link_path)) { return in_desc; } in_desc.link = addWatcher(in_desc.inot, link_path); in_desc.file = addWatcher(in_desc.inot, file_path); return in_desc; }
void ChunkManager::recreateMissingFiles() { createFiles(); if (tor.isMultiFile()) { // loop over all files and mark all chunks of all missing files as // not downloaded for (Uint32 i = 0;i < tor.getNumFiles();i++) { TorrentFile & tf = tor.getFile(i); if (!tf.isMissing()) continue; for (Uint32 j = tf.getFirstChunk(); j <= tf.getLastChunk();j++) resetChunk(j); tf.setMissing(false); } } else { // reset all chunks in case of single file torrent for (Uint32 j = 0; j < tor.getNumChunks();j++) resetChunk(j); } d->saveIndexFile(); d->recalc_chunks_left = true; chunksLeft(); }
int main() { int result; result = createFiles(100); return (result != 0); }
//------------------------------------------------------------------- // test1() calls the function test(int t) to repeatly test the joins. //------------------------------------------------------------------- int SMJTester::test1() { Status status; createFiles(); for (int i=1; i<=7; i++) { status=test(i); if (status!=OK) { cout<<"Test "<<i<<" Failed.\n"<<endl; break; } } return status==OK; }
void Foam::functionObjectFile::resetName(const word& name) { names_.clear(); names_.insert(name); if (Pstream::master()) { filePtrs_.clear(); filePtrs_.setSize(1); createFiles(); } }
void Foam::functionObjectFile::resetNames(const wordList& names) { names_.clear(); names_.insert(names); if (Pstream::master()) { filePtrs_.clear(); filePtrs_.setSize(names_.toc().size()); createFiles(); } }
int main(){ time_t t1, t2; double t0; time(&t1); FILE *dataFile; dataFile = fopen("cs451.conf", "r"); if (dataFile == NULL) { printf("cannot open file\n"); exit(0); } char temp[128]; char item[128]; char maxProcesses[42], timeQuantum[42]; while(fscanf(dataFile, "%s", temp) != EOF) { if (strstr(temp, "processes:") != NULL) { fscanf(dataFile, "%s", maxProcesses); } else if (strstr(temp, "quantum:") != NULL) { fscanf(dataFile, "%s", timeQuantum); } else if (strstr(temp, ":") != NULL) { fscanf(dataFile, "%s", item); } } fclose(dataFile); createFiles(); fillQueue(atoi(maxProcesses)); //printQueue(); simulate(atoi(maxProcesses)); freeStuff(); deleteFiles(); time(&t2); t0 = difftime(t2, t1); printf("Program run-time: %.0f seconds\n", t0); }
int main(int argc, char **argv) { int ret = X_FAILURE; if(argc < 2) { logMsg("Give the Source file"); return 1; } printf("Starting with ..%s\n", argv[1]); ret = createFiles(argv[1]); if(ret == X_FAILURE) { printf("yooo\n"); return 1; } return processFile(argv[1]); }
/** Call all tests */ GLDEF_C void CallTestsL() { TInt r = client.CreateLocal(0); FailIfError(r); gFileSize = 8; CSelectionBox* TheSelector = CSelectionBox::NewL(test.Console()); // Each test case of the suite has an identifyer for parsing purposes of the results gTestHarness = 6; gTestCase = 1; PrintHeaders(1, _L("t_fsrmkdir. Mkdir")); if(gMode == 0) { // Manual gSessionPath=_L("?:\\"); TCallBack createFiles(TestFileCreate, TheSelector); TCallBack MkDir(TestMake, TheSelector); TCallBack makeMultSame(TestMakeMultSame, TheSelector); TCallBack makeMultDif(TestMakeMultDif, TheSelector); TCallBack makeAll(TestAll, TheSelector); TheSelector->AddDriveSelectorL(TheFs); TheSelector->AddLineL(_L("Create all files"), createFiles); TheSelector->AddLineL(_L("Mkdir "), MkDir); TheSelector->AddLineL(_L("Mkdir mult clients same dir "), makeMultSame); TheSelector->AddLineL(_L("Mkdir mult clients dif dir"), makeMultDif); TheSelector->AddLineL(_L("Execute all options"), makeAll); TheSelector->Run(); } else { // Automatic TestAll(TheSelector); } client.Close(); test.Printf(_L("#~TestEnd_%d\n"), gTestHarness); delete TheSelector; }
/** Call all tests */ GLDEF_C void CallTestsL() { TInt r = client.CreateLocal(0); FailIfError(r); CSelectionBox* TheSelector = CSelectionBox::NewL(test.Console()); // Each test case of the suite has an identifyer for parsing purposes of the results gTestHarness = 3; gTestCase = 1; CreateDirWithNFiles(300, 3); PrintHeaders(1, _L("t_fsrdirscan. Directory scanning")); if(gMode==0) { // Manual gSessionPath=_L("?:\\"); TCallBack createFiles(TestFileCreate,TheSelector); TCallBack findFile(TestFindEntry,TheSelector); TCallBack findFileMC(TestFindEntryMultipleClients,TheSelector); TCallBack findFileMCDD(TestFindEntryMultipleClientsDD,TheSelector); TCallBack findFilePattern(TestFileFindPattern,TheSelector); TheSelector->AddDriveSelectorL(TheFs); TheSelector->AddLineL(_L("Create all files"),createFiles); TheSelector->AddLineL(_L("Find filename"),findFile); TheSelector->AddLineL(_L("Find with mult clients same directory"),findFileMC); TheSelector->AddLineL(_L("Find with mult clients dif directories"),findFileMCDD); TheSelector->AddLineL(_L("All using glob patterns"),findFilePattern); TheSelector->Run(); } else { // Automatic TestAll(TheSelector); } client.Close(); test.Printf(_L("#~TestEnd_%d\n"), gTestHarness); delete TheSelector; }
/** Call all tests */ GLDEF_C void CallTestsL() { CSelectionBox* TheSelector = CSelectionBox::NewL(test.Console()); // Each test case of the suite has an identifyer for parsing purposes of the results gTestHarness = 0; if(gMode == 0) { // Manual gSessionPath=_L("?:\\"); TCallBack createFiles(TestFileCreate,TheSelector); TheSelector->AddDriveSelectorL(TheFs); TheSelector->AddLineL(_L("Create all files"),createFiles); TheSelector->Run(); } else { // Automatic TestAll(TheSelector); } delete TheSelector; }
int main(int argc, char **argv) { /* umsg32 retval; resume(create(shell, 4096, 1, "shell", 1, CONSOLE)); retval = recvclr(); while (TRUE) { retval = receive(); kprintf("\n\n\rMain process recreating shell\n\n\r"); resume(create(shell, 4096, 1, "shell", 1, CONSOLE)); } return OK; */ uint32 nBlocks = 8192; char *a = "8192"; kprintf("Total blocks in the disk %s\r\n",a); kprintf("Total size of the disk %d\r\n",nBlocks*RAMD_BLKSZ); kprintf("opening the ramd disk drive\r\n"); if((diskId = open(RDISK,a,NULL)) == SYSERR) { kprintf("Failed to open ramdisk \r\n"); return SYSERR; } int iblockCount = 1024*4; kprintf("Creating initially empty file sytem on disk with %d iblocks\r\n",iblockCount); if(SYSERR == control(LFILESYS,LF_CTL_FORMAT,iblockCount,nBlocks* RAMD_BLKSZ)) { kprintf("File system creation failed\r\n"); return SYSERR; } lfsckfmt(RDISK); kprintf("Creating Direcotry \r\n"); char *dirPath ="/dir1"; if(control(LFILESYS,LF_CTL_MKDIR,(int)dirPath,0) == SYSERR) { kprintf("Direcotry creation failed\r\n"); return SYSERR; } kprintf("Creating Direcotry /dir1/dir2\r\n"); dirPath ="/dir1/dir2"; if(control(LFILESYS,LF_CTL_MKDIR,(int)dirPath,0) == SYSERR) { kprintf("Direcotry creation failed\r\n"); return SYSERR; } kprintf("Creating Direcotry /dir1/dir2/dir3\r\n"); dirPath ="/dir1/dir2/dir3"; if(control(LFILESYS,LF_CTL_MKDIR,(int)dirPath,0) == SYSERR) { kprintf("Direcotry creation failed\r\n"); return SYSERR; } createFiles(); /* int i =0; for(i=1;i<25l;++i) { kprintf("Opening file named %d\r\n",i); char name[20]; itoa(i,name); int fd = open(LFILESYS,name,"n"); if(fd == SYSERR) { kprintf("file open failed for %s\r\n",name); } kprintf("closing file named %d\r\n",i); close(fd); kprintf("Total files %d\r\n",Lf_data.lf_dir.lfd_nfiles); } kprintf("Calling list files\r\n"); listfiles();*/ return OK; }
int createArchive(char** files, int nb_fichiers) { if (strcmp(nom_archive, "") == 0 || nom_archive == NULL) nom_archive = files[0]; int archive = open(nom_archive, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU); if (archive == -1) // si on a pas pu ouvrir le fichier { printf("L'archive n'a pas pu être ouverte\n"); return EXIT_FAILURE; } printf("Création de l'archive %s\n", nom_archive); ListeDescripteurs descripteurs; // pour mémoriser les descripteurs de tous les fichiers / dossiers + archive (spécial) int nb_descripteurs = 0; descripteurs = construireListeVide(); nb_descripteurs = createFiles(files, nb_fichiers, &descripteurs, archive); // on traite tous nos fichiers en paramètre tete(descripteurs); uint** all_d = getTousLesDescripteursToInt(descripteurs); int j; uint premierDescripteur = (uint) lseek(archive, 0, SEEK_CUR); int i; if (affiche) printf("Ecriture de la configuration de l'archive...... "); for (i = 0; i < nb_descripteurs; i++) { int nb_int = taille(all_d[i]); int dernier_int = taille(all_d[0]); all_d[0] = (uint*) realloc(all_d[0], nb_int * sizeof(int) * sizeof(all_d[0])); for(j=0 ; j<nb_int ; j++){ all_d[0][j+dernier_int] = all_d[i][j]; } int ecrit = write(archive, &all_d[i], nb_int); if ((ecrit < 0) || (ecrit != nb_int)) printf("Erreur lors l'écriture de la configuration de l'archive !\n"); } detruireListeInt(all_d, nb_descripteurs); detruireListeDescripteurs(descripteurs); write(archive, &premierDescripteur, sizeof(uint)); if (affiche) printf("Done\n"); if (compresse) compression(archive); if (close(archive) == -1) { printf("Attention, l'archive n'a pas pu être fermée... Possibilité de corruption du fichier !"); return EXIT_FAILURE; } return EXIT_SUCCESS; }
void Foam::functionObjectFile::write() { createFiles(); }