示例#1
0
文件: main.c 项目: Socolcol/Splitter
void initProgram()
{
    bdoRootFolder = oneLevelDown(getCurrentPath());

    if (!backupExists())
    {
        createBackup();
    }

    printf("\nCounting files...\n\n");
    // Counts how many files there is in the "files_to_patch" folder assigns to filesToPatchCount,
    // and get all the file names in folders and sub folders and returns them as an array of strings
    char** fileNames = getAllFiles(FILES_TO_PATCH_FOLDER_NAME,"*",&filesToPatchCount);

    if (filesToPatchCount == 0)
    {
        printf("No files present in %s\n\n",FILES_TO_PATCH_FOLDER_NAME);
        system("PAUSE");
        exit(1);
    }

    printf("%ld files were found in %s\n\n", filesToPatchCount, FILES_TO_PATCH_FOLDER_NAME);

    filesToPatch = (FileToPatch*)malloc(filesToPatchCount * sizeof(FileToPatch));

    long i = 0;
    for (i = 0; i < filesToPatchCount; i++)
    {
        filesToPatch[i].fileName = fileNames[i];
        filesToPatch[i].patched = 0;
    }
}
示例#2
0
// Save Controller and delete the backup
void Controller::save()
{
	if(saveController(fileName))
	{
		if (backupExists())
		{
			if(!deleteBackup())
				throw std::runtime_error(controllerName + "::save : Entries backup was not deleted");
		}
	}
	else
		throw std::runtime_error(controllerName + "::save : Entries save file could not be opened");
}