/**
  \brief Open's a new file dialog
  */
void cwFileDialogHelper::open() {
    QStringList files;
    if(multipleFiles()) {
        files = cwGlobals::openFiles(caption(), filter(), settingKey());
    } else {
        QString file = cwGlobals::openFile(caption(), filter(), settingKey());
        files.append(file);
    }

    if(!files.isEmpty()) {
        emit filesSelected(files);
    }
}
Beispiel #2
0
/**
 * Tests a number of files in the root folder.
 */
int multipleFilesTest() {
    int hr = SUCCESS;
    int numFiles = 50;
    int maxFileSize = 10 * SD_SECTORSIZE;

    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(initFS());
    FAIL_BRK4(multipleFiles("file", numFiles, maxFileSize));

    Fail:

    saveAndCloseDisk();
    PRINT_RESULTS("Multiple Files Test");
    return hr;
}
Beispiel #3
0
/**
 * Tests the algorithm for performance
 */
int perfTest() {
    int hr = SUCCESS;
    int i;
    char *fileName = malloc(32);
    char *dirName = malloc(32);

    printf("###########################\n");
    printf("Let the competition begin!\n");

    FAIL_BRK4(initAndLoadDisk());
    FAIL_BRK4(initFS());

    // lots of files
    FAIL_BRK4(multipleFiles("file", 900, SD_SECTORSIZE));

    // deleting them
    for (i = 0; i < 900; i++) {
        sprintf(fileName, "file%05d", i);
        FAIL_BRK4(sfs_rm(fileName));
    }

    // lots of files again
    FAIL_BRK4(multipleFiles("file", 900, SD_SECTORSIZE));

    // now deleting them in reverse
    for (i = 900 - 1; i >= 0; i--) {
        sprintf(fileName, "file%05d", i);
        FAIL_BRK4(sfs_rm(fileName));
    }

    // one very big file
    FAIL_BRK4(singleBigFile("huge.txt", (SD_NUMSECTORS - 100) * SD_SECTORSIZE));
    // and now it is gone
    FAIL_BRK4(sfs_rm("huge.txt"));

    // lots of flat folders
    FAIL_BRK4(createFolders("dir", 900));
    for (i = 0; i < 900; i++) {
        sprintf(dirName, "dir%04d", i);
        FAIL_BRK4(sfs_rm(dirName));
    }

    // lots of nested folders
    FAIL_BRK4(nestedFolders("dir", 900));


    // going to the bottom
    FAIL_BRK3(sfs_fcd("/"), stdout, "Error: cd / failed\n");
    for (i = 0; i < 900; i++) {
        sprintf(dirName, "dir%04d", i);
        FAIL_BRK3(sfs_fcd(dirName), stdout , "Error: fcd to (%s) failed\n", dirName);
    }

    // deleting them on the way out
    for (i = 900 - 1; i >= 0; i--) {
        sprintf(dirName, "dir%04d", i);
        FAIL_BRK3(sfs_fcd(".."), stdout, "Error: cd .. failed\n");
        FAIL_BRK3(sfs_rm(dirName), stdout, "Error: rm (%s) failed\n", dirName);
    }


    Fail:

    SAFE_FREE(fileName);
    SAFE_FREE(dirName);
    printf("COMPETITION RESULTS: ");
    saveAndCloseDisk();
    PRINT_RESULTS("Performance Test");
    return hr;
}