2 * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef _pbd_archive_h_
20 #define _pbd_archive_h_
24 #include "pbd/signals.h"
27 #include "pbd/libpbd_visibility.h"
33 class LIBPBD_API FileArchive
36 FileArchive (const std::string& url);
38 int inflate (const std::string& destdir);
39 std::vector<std::string> contents ();
41 /* these are mapped to libarchive's lzmaz
42 * compression level 0..9
44 enum CompressionLevel {
50 int create (const std::string& srcdir, CompressionLevel compression_level = CompressGood);
51 int create (const std::map <std::string, std::string>& filemap, CompressionLevel compression_level = CompressGood);
53 PBD::Signal2<void, size_t, size_t> progress; // TODO
61 pthread_mutex_init (&_lock, NULL);
62 pthread_cond_init (&_ready, NULL);
72 pthread_mutex_destroy (&_lock);
73 pthread_cond_destroy (&_ready);
88 void lock () { pthread_mutex_lock (&_lock); }
89 void unlock () { pthread_mutex_unlock (&_lock); }
90 void signal () { pthread_cond_signal (&_ready); }
91 void wait () { pthread_cond_wait (&_ready, &_lock); }
100 FileArchive* progress;
103 pthread_mutex_t _lock;
104 pthread_cond_t _ready;
109 Request (const std::string& u)
112 url = strdup (u.c_str());
123 bool is_remote () const
125 if (!strncmp (url, "https://", 8) || !strncmp (url, "http://", 7) || !strncmp (url, "ftp://", 6)) {
140 std::vector<std::string> contents_url ();
141 std::vector<std::string> contents_file ();
146 int do_extract (struct archive* a);
147 std::vector<std::string> get_contents (struct archive *a);
156 #endif // _reallocpool_h_