gcString MCFManager::generatePath(DesuraId id, MCFBranch branch, MCFBuild build, bool isUnAuthed) { gcString fileName("b{0}_m{1}.mcf", branch, build); if (isUnAuthed) fileName = gcString("b{0}_m{1}_unauthed.mcf", branch, build); return gcString("{0}{1}{2}", m_szMCFSavePath, DIRS_STR, id.getFolderPathExtension(fileName.c_str())); }
gcString MCFManager::newMcfBackup(DesuraId gid, DesuraId mid) { gcString curPath = getMcfBackup(gid, mid); if (curPath != "") return curPath; gcString parPath; gcString parFile; size_t x=0; do { if (x==0) parFile = gcString("backup_{0}.mcf", mid.toInt64()); else parFile = gcString("backup_{0}_{1}.mcf", mid.toInt64(), x); parPath = gcString("{0}{1}{2}", m_szMCFSavePath, DIRS_STR, gid.getFolderPathExtension(parFile.c_str())); x++; } while ( UTIL::FS::isValidFile(UTIL::FS::PathWithFile(parPath)) ); gcString szItemDb = getMcfDb(m_szAppDataPath.c_str()); try { sqlite3x::sqlite3_connection db(szItemDb.c_str()); sqlite3x::sqlite3_command cmd(db, "INSERT INTO mcfbackup VALUES (?,?,?);"); cmd.bind(1, (long long int)gid.toInt64()); cmd.bind(2, (long long int)mid.toInt64()); cmd.bind(3, UTIL::OS::getRelativePath(parPath)); cmd.executenonquery(); } catch (std::exception &e) { Warning("Failed to update mcf backup: {0}\n", e.what()); } return parPath; }