36 #include <archive_entry.h>
42 #define BUFF_SIZE 8192
62 char* cast_buf = (
char*) buffer;
64 std::ostream &os = *(std::ostream*)ostream_ptr;
65 os.write(cast_buf, length);
75 std::istream &is = *(std::istream*)istream_ptr;
91 struct archive_entry *entry;
94 a = archive_read_new();
95 archive_read_support_filter_all(a);
96 archive_read_support_compression_all(a);
97 archive_read_support_format_tar(a);
101 while ((ret = archive_read_next_header(a, &entry)) == ARCHIVE_OK )
106 fd = open(filename.
getPath().c_str(),O_CREAT|O_WRONLY,0600);
108 archive_read_data_into_fd(a,fd);
112 archive_read_free(a);
117 bool processed =
false;
121 a = archive_write_new();
122 archive_write_set_format_ustar(a);
125 for(std::set<ObservedFile>::const_iterator of_iter = files_to_send.begin(); of_iter != files_to_send.end(); ++of_iter)
130 struct archive_entry *entry;
131 entry = archive_entry_new();
132 archive_entry_set_size(entry, file.
size());
136 archive_entry_set_filetype(entry, AE_IFDIR);
137 archive_entry_set_perm(entry, 0755);
141 archive_entry_set_filetype(entry, AE_IFREG);
142 archive_entry_set_perm(entry, 0644);
145 archive_entry_set_pathname(entry, rel_filename(root, of).c_str());
149 clock_gettime(CLOCK_REALTIME, &ts);
150 archive_entry_set_atime(entry, ts.tv_sec, ts.tv_nsec);
151 archive_entry_set_birthtime(entry, ts.tv_sec, ts.tv_nsec);
152 archive_entry_set_ctime(entry, ts.tv_sec, ts.tv_nsec);
153 archive_entry_set_mtime(entry, ts.tv_sec, ts.tv_nsec);
155 archive_write_header(a, entry);
180 if( (ret = archive_write_data(a, buff, len)) < 0)
189 }
catch (
const std::bad_cast&) { };
198 std::ifstream fs(file.
getPath().c_str());
207 if( (ret = archive_write_data(a, buff, fs.gcount())) < 0)
218 archive_entry_free(entry);
219 archive_write_close(a);
220 archive_write_free(a);
225 archive_entry_free(entry);
227 archive_write_close(a);
228 archive_write_free(a);
240 if (parent.
getFile().
isRoot())
return file_path.substr(parent_path.length(), file_path.length() - parent_path.length());
243 return file_path.substr(parent_path.length() + 1, file_path.length() - parent_path.length() - 1);