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; } }
/*! * \brief Database::~Database */ Database::~Database() { delete m_albumTable; delete m_mediaTable; delete m_db; createBackup(); }
bool executeBackupCommand(const std::string& command, const std::vector<std::string>& commandArgs) { try { if (command == "backups") { if (backups_.empty()) { std::cout << "No backups" << std::endl; } else { std::cout << "Backups:" << std::endl; for (Backup& backup : backups_) { std::cout << backup.name() << std::endl; } } } else if (command == "backup") { if (commandArgs.empty()) { std::cout << "You need specify backup name" << std::endl; } else { const std::string& backupName = commandArgs.at(0); createBackup(backupName); } } else if (command == "restore") { if (commandArgs.empty()) { std::cout << "You need specify backup name" << std::endl; } else { const std::string& backupName = commandArgs.at(0); restoreBackup(backupName); } } else { return false; } } catch (const AlreadyExistException& e) { std::cout << "Exception: " << e.what() << std::endl; } catch (const DoesntExistException& e) { std::cout << "Exception: " << e.what() << std::endl; } catch (const std::exception& e) { std::cout << "Exception: " << e.what() << std::endl; } return true; }