// // Created by Stepan Usatiuk on 23.05.2023. // #ifndef SEMBACKUP_COMMANDSCOMMON_H #define SEMBACKUP_COMMANDSCOMMON_H #include #include #include namespace CommandsCommon { // Bytes written, bytes skipped, files written using workerStatsFunction = std::function; /// Internat function for recursive directory processing, taking into account ".ignore" and ".nobackup" files /// \param dir Const reference to the path of directory to iterate through /// \param ignore List of files to ignore /// \param spawner Function to spawn other tasks /// \param processFile Task to spawn on found files void processDirWithIgnore(const std::filesystem::path &dir, std::vector ignore, std::function)> spawner, std::function processFile); struct WorkerStats { public: std::atomic bytesWritten = 0; std::atomic bytesSkipped = 0; std::atomic filesWritten = 0; }; struct RunnerStats { public: std::atomic bytesToSave = 0; std::atomic filesToSaveCount = 0; std::atomic filesSkipped = 0; }; /// Checks if \p p has \p prefix as prefix /// \param prefix Constant reference to the prefix path /// \param p Constant reference to the checked path /// \return True if \p p contains \p prefix at its prefix, False otherwise bool isSubpath(const std::filesystem::path &prefix, const std::filesystem::path &p); void workerCallback(unsigned long long bytesWritten, unsigned long long bytesSkipped, unsigned long long filesWritten, WorkerStats &to); };// namespace CommandsCommon #endif//SEMBACKUP_COMMANDSCOMMON_H