Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

FileBackup.hpp 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // FileBackup.hpp
  2. //
  3. // Copyright (C) 2011 ARM Research Labs, LLC.
  4. // See www.armresearch.com for the copyright terms.
  5. //
  6. // This file defines the interface used by the FileBackup class.
  7. //
  8. #ifndef FileBackuphpp_included
  9. #define FileBackuphpp_included
  10. #include <string>
  11. #include <vector>
  12. /// FileBackup class.
  13. //
  14. // This class provides capability to manage the backup and restore of
  15. // disk files.
  16. //
  17. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  18. class FileBackup {
  19. public:
  20. /// Create a backup of the specified file.
  21. //
  22. // This method creates a backup of the specified file The name of
  23. // the link is the name of the file appended by the BackupSuffix
  24. // data member.
  25. //
  26. // The file can be restored from the backup by RestoreFromBackup.
  27. //
  28. // \param[in] File is the file name to create a backup for.
  29. //
  30. // \throws std::runtime_error if an error is encountered.
  31. //
  32. // \see RestoreAllFilesFromBackup().
  33. //
  34. void CreateBackupFile(std::string File);
  35. /// Remove the backups of all the specified files.
  36. //
  37. // This method removes the backup of the files specified by the
  38. // CreateBackup() method.
  39. //
  40. // \throws std::runtime_error if an error is encountered.
  41. //
  42. void RemoveAllBackupFiles();
  43. /// Restore the all the specified files from the backup.
  44. //
  45. // This method restores the backup of the files specified by the
  46. // CreateBackupFile() method.
  47. //
  48. // \throws std::runtime_error if an error is encountered.
  49. //
  50. // \see CreateBackupFile().
  51. //
  52. void RestoreAllFilesFromBackup();
  53. /// Get the name of the backup file.
  54. //
  55. // \param[in] File is the name of the file to back up.
  56. //
  57. // \returns the name of the backup file.
  58. //
  59. static std::string GetBackupFileName(std::string File);
  60. private:
  61. /// Copy a file.
  62. //
  63. // \param[in] From is the name of the file to copy from.
  64. //
  65. // \param[in] To is the name of the file to copy to.
  66. //
  67. // \throws runtime_error in case of error.
  68. //
  69. void CopyFile(std::string From, std::string To);
  70. /// Suffix to append to the file name to obtain the backup file
  71. /// name.
  72. static const std::string BackupSuffix;
  73. /// Typedef for container of names of files.
  74. typedef std::vector<std::string> FilenameContainer;
  75. /// Container of files that have backups.
  76. FilenameContainer BackedUpFile;
  77. };
  78. #endif