\class cmArchiveWrite * \brief Wrapper around libarchive for writing. * */
| 38 | * |
| 39 | */ |
| 40 | class cmArchiveWrite |
| 41 | { |
| 42 | public: |
| 43 | /** Compression type. */ |
| 44 | enum Compress |
| 45 | { |
| 46 | CompressNone, |
| 47 | CompressCompress, |
| 48 | CompressGZip, |
| 49 | CompressBZip2, |
| 50 | CompressLZMA, |
| 51 | CompressXZ, |
| 52 | CompressZstd, |
| 53 | CompressPPMd, |
| 54 | }; |
| 55 | |
| 56 | /** Construct with output stream to which to write archive. */ |
| 57 | cmArchiveWrite(std::ostream& os, Compress c = CompressNone, |
| 58 | std::string const& format = "paxr", int compressionLevel = 0, |
| 59 | int numThreads = 1); |
| 60 | |
| 61 | ~cmArchiveWrite(); |
| 62 | |
| 63 | cmArchiveWrite(cmArchiveWrite const&) = delete; |
| 64 | cmArchiveWrite& operator=(cmArchiveWrite const&) = delete; |
| 65 | |
| 66 | bool Open(); |
| 67 | |
| 68 | /** |
| 69 | * Add a path (file or directory) to the archive. Directories are |
| 70 | * added recursively. The "path" must be readable on disk, either |
| 71 | * full path or relative to current working directory. The "skip" |
| 72 | * value indicates how many leading bytes from the input path to |
| 73 | * skip. The remaining part of the input path is appended to the |
| 74 | * "prefix" value to construct the final name in the archive. |
| 75 | */ |
| 76 | bool Add(std::string path, size_t skip = 0, char const* prefix = nullptr, |
| 77 | bool recursive = true); |
| 78 | |
| 79 | /** Returns true if there has been no error. */ |
| 80 | explicit operator bool() const { return this->Okay(); } |
| 81 | |
| 82 | /** Returns true if there has been an error. */ |
| 83 | bool operator!() const { return !this->Okay(); } |
| 84 | |
| 85 | /** Return the error string; empty if none. */ |
| 86 | std::string GetError() const { return this->Error; } |
| 87 | |
| 88 | // TODO: More general callback instead of hard-coding calls to |
| 89 | // std::cout. |
| 90 | void SetVerbose(bool v) { this->Verbose = v; } |
| 91 | |
| 92 | void SetMTime(std::string const& t) { this->MTime = t; } |
| 93 | |
| 94 | //! Sets the permissions of the added files/folders |
| 95 | void SetPermissions(int permissions_) |
| 96 | { |
| 97 | this->Permissions.Set(permissions_); |
nothing calls this directly
no test coverage detected
searching dependent graphs…