tarfile.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __REUSE_TARFILE_H__
00023 #define __REUSE_TARFILE_H__
00024
00025 #include "dll.h"
00026 #include <string>
00027 #include <stdexcept>
00028 #include <libtar.h>
00029
00030 namespace Barry {
00031 class Data;
00032 }
00033
00034 namespace reuse {
00035
00036
00037
00038
00039
00040
00041
00042 extern tartype_t gztar_ops_nonthread;
00043
00044 class BXLOCAL TarFile
00045 {
00046 TAR *m_tar;
00047 bool m_throw;
00048 bool m_writemode;
00049 std::string m_last_error;
00050
00051 private:
00052 bool False(const char *msg);
00053 bool False(const std::string &str) { return False(str.c_str()); }
00054 bool False(const std::string &msg, int err);
00055
00056 public:
00057 class TarError : public std::runtime_error
00058 {
00059 public:
00060 TarError(const std::string &msg) : std::runtime_error(msg) {}
00061 };
00062
00063 public:
00064 explicit TarFile(const char *filename, bool write = false,
00065 tartype_t *compress_ops = 0, bool always_throw = false);
00066 ~TarFile();
00067
00068 const std::string& get_last_error() const { return m_last_error; }
00069
00070 bool Close();
00071
00072
00073
00074
00075 bool AppendFile(const char *tarpath, const std::string &data);
00076
00077
00078
00079
00080 bool ReadNextFile(std::string &tarpath, std::string &data);
00081 bool ReadNextFile(std::string &tarpath, Barry::Data &data);
00082
00083
00084
00085 bool ReadNextFilenameOnly(std::string &tarpath);
00086 };
00087
00088 }
00089
00090 #endif
00091