/* * ArchiveWriter.hh * * Created on: 26 sept. 2013 * Author: CS */ #ifndef ARCHIVEWRITER_HH_ #define ARCHIVEWRITER_HH_ #include #include #include struct archive; struct archive_entry; namespace postprocessing { class ArchiveWriter { public: /** * Archive formats available. */ enum Formats { TAR = 0, ZIP = 1 }; ArchiveWriter(const std::string& pArchiveFileName, const Formats& pFormat); virtual ~ArchiveWriter(); /** * Adds a file to the current archive. */ void addFile(const std::string& pFilePath, const std::string& pEntryName = ""); /** * Closes the current archive. */ void close(); /** * Creates an archive with the given format and adds all given files. */ static std::string createArchive(const Formats& pFormat, const std::string& pExtension, const std::vector& pFiles, const std::string& pPrefix, const std::string& pOutDir = std::string()); private: void checkError(const int pErrCode, const bool pCloseBeforeThrow = false); /** * Opens entry and adds meta-data for a given entry file. */ void addHeader(const std::string& pFilePath, const std::string& pEntryName = ""); /** * Close current entry. */ void addFinish(); /** * Flag to indicate the archive is closed or not. */ bool _open; /** * The current archive to write. */ archive* _archive; /** * The current entry. */ archive_entry* _entry; const std::string _archiveFileName; /** * The current archive format (zip, tar etc.) */ const Formats _format; /** * A logger. */ static log4cxx::LoggerPtr _logger; }; } /* namespace postprocessing */ #endif /* ARCHIVEWRITER_HH_ */