// // TBackupProfile // TBackupProfile::TBackupProfile(const PJsonVal& SettingsJson, const TStr& Destination_, const TStr& ProfileName_) { Destination = Destination_; if (Destination.Len() > 0 && (Destination.LastCh() != '\\' || Destination.LastCh() != '/')) Destination += "/"; ProfileName = ProfileName_; if (!TDir::Exists(Destination)) TDir::GenDir(Destination); VersionsToKeep = SettingsJson->GetObjInt("versionsToKeep", 1); PJsonVal FoldersJson = SettingsJson->GetObjKey("folders"); EAssertR(FoldersJson->IsArr(), "Expected to get an array of folders"); for (int N = 0; N < FoldersJson->GetArrVals(); N++) { PJsonVal FolderJson = FoldersJson->GetArrVal(N); TBackupFolderInfo FolderInfo; FolderInfo.Folder = FolderJson->GetObjStr("folder"); if (FolderJson->IsObjKey("extensions")) FolderJson->GetObjStrV("extensions", FolderInfo.Extensions); if (FolderInfo.Extensions.IsIn("*")) FolderInfo.Extensions.Clr(); FolderInfo.IncludeSubfolders = FolderJson->GetObjBool("includeSubfolders"); if (FolderJson->IsObjKey("skipIfContaining")) FolderJson->GetObjStrV("skipIfContaining", FolderInfo.SkipIfContainingV); FolderV.Add(FolderInfo); } // load logs of the previous backups ProfileLogFile = Destination + ProfileName + "/backupInfo.json"; if (TFile::Exists(ProfileLogFile)) { PJsonVal LogJson = TJsonVal::GetValFromStr(TStr::LoadTxt(ProfileLogFile)); if (LogJson->IsArr()) { for (int N = 0; N < LogJson->GetArrVals(); N++) { PJsonVal Log = LogJson->GetArrVal(N); LogV.Add(TBackupLogInfo(Log)); } } } }