123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- // FileBackup.hpp
- //
- // Copyright (C) 2011 ARM Research Labs, LLC.
- // See www.armresearch.com for the copyright terms.
- //
- // This file defines the interface used by the FileBackup class.
- //
-
- #ifndef FileBackuphpp_included
- #define FileBackuphpp_included
-
- #include <string>
- #include <vector>
-
- /// FileBackup class.
- //
- // This class provides capability to manage the backup and restore of
- // disk files.
- //
- //////////////////////////////////////////////////////////////////////////////////////////////////////////
- class FileBackup {
-
- public:
-
- /// Create a backup of the specified file.
- //
- // This method creates a backup of the specified file The name of
- // the link is the name of the file appended by the BackupSuffix
- // data member.
- //
- // The file can be restored from the backup by RestoreFromBackup.
- //
- // \param[in] File is the file name to create a backup for.
- //
- // \throws std::runtime_error if an error is encountered.
- //
- // \see RestoreAllFilesFromBackup().
- //
- void CreateBackupFile(std::string File);
-
- /// Remove the backups of all the specified files.
- //
- // This method removes the backup of the files specified by the
- // CreateBackup() method.
- //
- // \throws std::runtime_error if an error is encountered.
- //
- void RemoveAllBackupFiles();
-
- /// Restore the all the specified files from the backup.
- //
- // This method restores the backup of the files specified by the
- // CreateBackupFile() method.
- //
- // \throws std::runtime_error if an error is encountered.
- //
- // \see CreateBackupFile().
- //
- void RestoreAllFilesFromBackup();
-
- /// Get the name of the backup file.
- //
- // \param[in] File is the name of the file to back up.
- //
- // \returns the name of the backup file.
- //
- static std::string GetBackupFileName(std::string File);
-
- private:
-
- /// Copy a file.
- //
- // \param[in] From is the name of the file to copy from.
- //
- // \param[in] To is the name of the file to copy to.
- //
- // \throws runtime_error in case of error.
- //
- void CopyFile(std::string From, std::string To);
-
- /// Suffix to append to the file name to obtain the backup file
- /// name.
- static const std::string BackupSuffix;
-
- /// Typedef for container of names of files.
- typedef std::vector<std::string> FilenameContainer;
-
- /// Container of files that have backups.
- FilenameContainer BackedUpFile;
-
- };
-
- #endif
|