From 1ca06b24127bc817b16d74f7734c8cd1ba49ec7a Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Tue, 26 Aug 2014 14:05:34 +0200 Subject: [PATCH] -(mod) renamed .tpp files to .ipp as code blocks editor doesn't recognise tpp out of the box -(mod) cleanup of archive reader code -(add) added new constructor for reader if we only need filter and no format -(add) added initial version of archive writer --- CMakeLists.txt | 8 +- archive_reader.cpp | 11 +- archive_reader.hpp | 16 ++- archive_reader.tpp => archive_reader.ipp | 11 ++ archive_writer.cpp | 131 +++++++++++++++++++++++ archive_writer.hpp | 88 +++++++++++++++ archive_writer.ipp | 50 +++++++++ archive_writer_entry.cpp | 124 +++++++++++++++++++++ archive_writer_entry.hpp | 77 +++++++++++++ archive_writer_filter.hpp | 53 +++++++++ archive_writer_format.hpp | 58 ++++++++++ 11 files changed, 615 insertions(+), 12 deletions(-) rename archive_reader.tpp => archive_reader.ipp (87%) create mode 100644 archive_writer.cpp create mode 100644 archive_writer.hpp create mode 100644 archive_writer.ipp create mode 100644 archive_writer_entry.cpp create mode 100644 archive_writer_entry.hpp create mode 100644 archive_writer_filter.hpp create mode 100644 archive_writer_format.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 17302f9..3a3a7c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ project(archive_cpp_wrapper) set(CMAKE_CXX_FLAGS "-Wall -std=c++11") file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") -file(GLOB template_implementations "${CMAKE_CURRENT_SOURCE_DIR}/*.tpp") +file(GLOB template_implementations "${CMAKE_CURRENT_SOURCE_DIR}/*.ipp") add_library( ${PROJECT_NAME} SHARED @@ -39,6 +39,9 @@ add_library( ${PROJECT_NAME} SHARED archive_reader_entry.cpp archive_reader_iterator.cpp archive_reader_entry_buffer.cpp + + archive_writer.cpp + archive_writer_entry.cpp archive_exception.cpp @@ -68,7 +71,8 @@ install( archive_reader_filter.hpp archive_reader_entry.hpp archive_writer.hpp - archive_reader.tpp + archive_reader.ipp + archive_writer.ipp DESTINATION include ) diff --git a/archive_reader.cpp b/archive_reader.cpp index d462d61..171f5f1 100644 --- a/archive_reader.cpp +++ b/archive_reader.cpp @@ -117,6 +117,8 @@ READER_INIT_FILTER(LZOP, lzop) READER_INIT_FILTER(GRZIP, gzip) /// ---------------- init_data ---------------- // +namespace ns_reader { + ssize_t reader_callback( archive* archive, void* in_reader_container, const void** buff ) { reader::reader_container* p_reader_container = reinterpret_cast( in_reader_container ); @@ -127,14 +129,11 @@ ssize_t reader_callback( archive* archive, void* in_reader_container, const void return p_reader_container->_stream.gcount(); } -int close_callback( archive*, void* ) -{ - return ARCHIVE_OK; -} +} // ns_reader void reader::init_data() { - if(archive_read_open( _archive.get(), &_reader_container, nullptr, reader_callback, close_callback ) != ARCHIVE_OK) + if(archive_read_open( _archive.get(), &_reader_container, nullptr, ns_reader::reader_callback, nullptr ) != ARCHIVE_OK) { throw archive_exception( "Failed to read the archive!" ); } @@ -150,4 +149,4 @@ ns_reader::iterator reader::end() return ns_reader::iterator( this, true ); } -} +} // ns_archive diff --git a/archive_reader.hpp b/archive_reader.hpp index 1e918a8..895fc0f 100644 --- a/archive_reader.hpp +++ b/archive_reader.hpp @@ -41,6 +41,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace ns_archive { +namespace ns_reader { + +ssize_t reader_callback( archive* archive, void* in_reader_container, const void** buff ); + +} // ns_reader + class reader { public: @@ -55,6 +61,9 @@ public: template static reader make_reader( std::istream& stream, size_t block_size); + template + static reader make_reader( std::istream& stream, size_t block_size); + ns_reader::entry* get_next_entry(); bool has_next_entry(); @@ -88,12 +97,11 @@ private: std::vector _buff; } _reader_container; - friend ssize_t reader_callback( archive* archive, void* in_reader_container, const void** buff ); - friend int close_callback( archive*, void* ); + friend ssize_t ns_reader::reader_callback( archive* archive, void* in_reader_container, const void** buff ); }; -} +} // ns_archive -#include "archive_reader.tpp" +#include "archive_reader.ipp" #endif // ARCHIVE_READER_HPP_INCLUDED diff --git a/archive_reader.tpp b/archive_reader.ipp similarity index 87% rename from archive_reader.tpp rename to archive_reader.ipp index ee97117..71a865a 100644 --- a/archive_reader.tpp +++ b/archive_reader.ipp @@ -49,4 +49,15 @@ reader reader::make_reader( std::istream& stream, size_t block_size ) return a_reader; } +template +reader reader::make_reader( std::istream& stream, size_t block_size ) +{ + reader a_reader( stream, block_size ); + a_reader.init_format(); + a_reader.init_filter(); + a_reader.init_data(); + + return a_reader; +} + } diff --git a/archive_writer.cpp b/archive_writer.cpp new file mode 100644 index 0000000..d343024 --- /dev/null +++ b/archive_writer.cpp @@ -0,0 +1,131 @@ +/* +BSD 2-Clause license + +Copyright (c) 2014, Domen Vrankar +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "archive_writer.hpp" + +#include "archive_exception.hpp" +#include "string" + +#include + +namespace ns_archive { + +writer::writer(std::ostream& stream) : + _archive( archive_write_new(), [](archive* archive){ archive_read_free(archive); } ), // errors in destructor will be silently ignored + _writer_container( stream ) +{ + // +} + +void writer::finish() +{ + archive_write_close(_archive.get()); // TODO throw on error +} + +void writer::add_entry( ns_writer::entry& entry ) +{ + if( archive_write_header( _archive.get(), entry.get_entry() ) != ARCHIVE_OK) + { + throw archive_exception( "Error writing header to archive!" ); + } + + auto& stream = entry.get_stream(); + std::istreambuf_iterator eos; + std::string tmp( std::istreambuf_iterator(stream), eos ); + + archive_write_data( _archive.get(), tmp.c_str(), tmp.size() ); +} + +/// ---------------- init_format ---------------- // + +#define WRITER_INIT_FORMAT(__FORMAT__, __FUNCTION_SUFFIX__) \ +template<> \ +void writer::init_format()\ +{\ + archive_write_set_format_##__FUNCTION_SUFFIX__(_archive.get());\ +} + +WRITER_INIT_FORMAT(7ZIP, 7zip) +WRITER_INIT_FORMAT(CPIO_SVR4_NOCRC, cpio_newc) +WRITER_INIT_FORMAT(ISO9660, iso9660) +WRITER_INIT_FORMAT(MTREE, mtree) +WRITER_INIT_FORMAT(SHAR, shar) +WRITER_INIT_FORMAT(SHAR_BASE, shar) +WRITER_INIT_FORMAT(SHAR_DUMP, shar_dump) +WRITER_INIT_FORMAT(TAR, pax_restricted) +WRITER_INIT_FORMAT(TAR_GNUTAR, gnutar) +WRITER_INIT_FORMAT(TAR_PAX_INTERCHANGE, pax) +WRITER_INIT_FORMAT(TAR_PAX_RESTRICTED, pax_restricted) +WRITER_INIT_FORMAT(TAR_USTAR, ustar) +WRITER_INIT_FORMAT(XAR, xar) +WRITER_INIT_FORMAT(ZIP, zip) + +/// ---------------- init_filter ---------------- // + +#define WRITER_INIT_FILTER(__FILTER__, __FUNCTION_SUFFIX__) \ +template<> \ +void writer::init_filter()\ +{\ + archive_write_add_filter_##__FUNCTION_SUFFIX__(_archive.get());\ +} + +WRITER_INIT_FILTER(NONE, none) +WRITER_INIT_FILTER(GZIP, gzip) +WRITER_INIT_FILTER(BZIP2, bzip2) +WRITER_INIT_FILTER(COMPRESS, compress) +WRITER_INIT_FILTER(GRZIP, grzip) +WRITER_INIT_FILTER(LRZIP, lrzip) +WRITER_INIT_FILTER(LZIP, lzip) +WRITER_INIT_FILTER(LZMA, lzma) +WRITER_INIT_FILTER(LZOP, lzip) +WRITER_INIT_FILTER(UU, uuencode) +WRITER_INIT_FILTER(XZ, xz) + +/// ---------------- init_data ---------------- // +namespace ns_writer { + +ssize_t writer_callback( archive* archive, void* out_writer_container, const void* buff, size_t buff_size ) +{ + std::ostream* stream = reinterpret_cast( out_writer_container ); + + stream->write( (const char*)buff, buff_size ); + + return buff_size; +} + +} // ns_writer + +void writer::init_data() +{ + if(archive_write_open( _archive.get(), &_writer_container, nullptr, ns_writer::writer_callback, nullptr ) != ARCHIVE_OK) + { + throw archive_exception( "Failed to write the archive!" ); + } +} + +} diff --git a/archive_writer.hpp b/archive_writer.hpp new file mode 100644 index 0000000..3b723ea --- /dev/null +++ b/archive_writer.hpp @@ -0,0 +1,88 @@ +/* +BSD 2-Clause license + +Copyright (c) 2014, Domen Vrankar +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef ARCHIVE_WRITER_HPP_INCLUDED +#define ARCHIVE_WRITER_HPP_INCLUDED + +#include +#include +#include + +#include "archive_writer_format.hpp" +#include "archive_writer_filter.hpp" +#include "archive_writer_entry.hpp" + +namespace ns_archive { + +namespace ns_writer { + +ssize_t writer_callback( archive* archive, void* out_writer_container, const void* buff, size_t buff_size ); + +} // ns_writer + +class writer +{ +public: + writer(writer&&) = default; + + writer(const writer&) = delete; + writer& operator=(const writer&) = delete; + + void finish(); + + template + static writer make_writer(std::ostream& stream); + + template + static writer make_writer(std::ostream& stream); + + void add_entry( ns_writer::entry& entry ); + +private: + writer(std::ostream& stream); + + template + void init_format(); + + template + void init_filter(); + + void init_data(); + + std::shared_ptr _archive; + std::ostream& _writer_container; + + friend ssize_t ns_writer::writer_callback( archive* archive, void* out_writer_container, const void* buff, size_t buff_size ); +}; + +} // ns_archive + +#include "archive_writer.ipp" + +#endif // ARCHIVE_WRITER_HPP_INCLUDED + diff --git a/archive_writer.ipp b/archive_writer.ipp new file mode 100644 index 0000000..dee5273 --- /dev/null +++ b/archive_writer.ipp @@ -0,0 +1,50 @@ +/* +BSD 2-Clause license + +Copyright (c) 2014, Domen Vrankar +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +namespace ns_archive { + +template +writer writer::make_writer(std::ostream& stream) +{ + writer a_writer( stream ); + a_writer.init_format(); + a_writer.init_filter(); + a_writer.init_data(); + + return a_writer; +} + +template +writer writer::make_writer(std::ostream& stream) +{ + return make_writer( stream ); +} + +} + + diff --git a/archive_writer_entry.cpp b/archive_writer_entry.cpp new file mode 100644 index 0000000..74195e2 --- /dev/null +++ b/archive_writer_entry.cpp @@ -0,0 +1,124 @@ +#include "archive_writer_entry.hpp" + +namespace ns_archive { +namespace ns_writer { + +entry::entry(std::istream& stream, size_t stream_size) : + _entry( archive_entry_new() ), + _stream( &stream ) +{ + archive_entry_set_mode( _entry, S_IFREG ); + archive_entry_set_size( _entry, stream_size ); +} + +void entry::clear_entry(std::istream& stream, size_t stream_size) +{ + archive_entry_clear( _entry ); + _stream = &stream; + archive_entry_set_mode( _entry, S_IFREG ); + archive_entry_set_size( _entry, stream_size ); +} + +//----------------------------------------------------// +void entry::set_header_value_gid(int64_t value) +{ + archive_entry_set_gid(_entry, value); +} + +void entry::set_header_value_ino(int64_t value) +{ + archive_entry_set_ino(_entry, value); +} + +void entry::set_header_value_ino64(int64_t value) +{ + archive_entry_set_ino64(_entry, value); +} + +void entry::set_header_value_size(int64_t value) +{ + archive_entry_set_size(_entry, value); +} + +void entry::set_header_value_uid(int64_t value) +{ + archive_entry_set_uid(_entry, value); +} + +void entry::set_header_value_mode(mode_t value) +{ + archive_entry_set_mode(_entry, value); +} + +void entry::set_header_value_perm(mode_t value) +{ + archive_entry_set_perm(_entry, value); +} + +void entry::set_header_value_rdev(dev_t value) +{ + archive_entry_set_rdev(_entry, value); +} + +void entry::set_header_value_rdevmajor(dev_t value) +{ + archive_entry_set_rdevmajor(_entry, value); +} + +void entry::set_header_value_rdevminor(dev_t value) +{ + archive_entry_set_rdevminor(_entry, value); +} + +void entry::set_header_value_gname(const std::string& value) +{ + archive_entry_set_gname(_entry, value.c_str()); +} + +void entry::set_header_value_hardlink(const std::string& value) +{ + archive_entry_set_hardlink(_entry, value.c_str()); +} + +void entry::set_header_value_link(const std::string& value) +{ + archive_entry_set_link(_entry, value.c_str()); +} + +void entry::set_header_value_pathname(const std::string& value) +{ + archive_entry_set_pathname(_entry, value.c_str()); +} + +void entry::set_header_value_symlink(const std::string& value) +{ + archive_entry_set_symlink(_entry, value.c_str()); +} + +void entry::set_header_value_uname(const std::string& value) +{ + archive_entry_set_uname(_entry, value.c_str()); +} + +void entry::set_header_value_nlink(unsigned int value) +{ + archive_entry_set_nlink(_entry, value); +} + +void entry::set_header_value_mtime(time_t time, long value) +{ + archive_entry_set_mtime(_entry, time, value); +} + +archive_entry* entry::get_entry() const +{ + return _entry; +} + +std::istream& entry::get_stream() const +{ + return *_stream; +} + +} +} diff --git a/archive_writer_entry.hpp b/archive_writer_entry.hpp new file mode 100644 index 0000000..d742354 --- /dev/null +++ b/archive_writer_entry.hpp @@ -0,0 +1,77 @@ +/* +BSD 2-Clause license + +Copyright (c) 2014, Domen Vrankar +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef ARCHIVE_WRITER_ENTRY_HPP_INCLUDED +#define ARCHIVE_WRITER_ENTRY_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace ns_archive { +namespace ns_writer { + +class entry +{ +public: + entry(std::istream& stream, size_t stream_size); + + void clear_entry(std::istream& stream, size_t stream_size); + + void set_header_value_gid(int64_t value); + void set_header_value_ino(int64_t value); + void set_header_value_ino64(int64_t value); + void set_header_value_size(int64_t value); + void set_header_value_uid(int64_t value); + void set_header_value_mode(mode_t value); + void set_header_value_perm(mode_t value); + void set_header_value_rdev(dev_t value); + void set_header_value_rdevmajor(dev_t value); + void set_header_value_rdevminor(dev_t value); + void set_header_value_gname(const std::string& value); + void set_header_value_hardlink(const std::string& value); + void set_header_value_link(const std::string& value); + void set_header_value_pathname(const std::string& value); + void set_header_value_symlink(const std::string& value); + void set_header_value_uname(const std::string& value); + void set_header_value_nlink(unsigned int value); + void set_header_value_mtime(time_t time, long value); + + archive_entry* get_entry() const; + std::istream& get_stream() const; +private: + archive_entry* _entry; + std::istream* _stream; +}; + +} +} + +#endif // ARCHIVE_WRITER_ENTRY_HPP_INCLUDED diff --git a/archive_writer_filter.hpp b/archive_writer_filter.hpp new file mode 100644 index 0000000..b9143a0 --- /dev/null +++ b/archive_writer_filter.hpp @@ -0,0 +1,53 @@ +/* +BSD 2-Clause license + +Copyright (c) 2014, Domen Vrankar +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef ARCHIVE_WRITER_FILTER_HPP_INCLUDED +#define ARCHIVE_WRITER_FILTER_HPP_INCLUDED + +namespace ns_archive { +namespace ns_writer { + +enum class filter +{ + _NONE, + _GZIP, + _BZIP2, + _COMPRESS, + _GRZIP, + _LRZIP, + _LZIP, + _LZMA, + _LZOP, + _UU, + _XZ +}; + +} +} + +#endif // ARCHIVE_WRITER_FILTER_HPP_INCLUDED diff --git a/archive_writer_format.hpp b/archive_writer_format.hpp new file mode 100644 index 0000000..1eac2ef --- /dev/null +++ b/archive_writer_format.hpp @@ -0,0 +1,58 @@ +/* +BSD 2-Clause license + +Copyright (c) 2014, Domen Vrankar +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef ARCHIVE_WRITER_FORMAT_HPP_INCLUDED +#define ARCHIVE_WRITER_FORMAT_HPP_INCLUDED + +namespace ns_archive { +namespace ns_writer { + +enum class format +{ + _7ZIP, + _CPIO, + _CPIO_POSIX, + _CPIO_SVR4_NOCRC, + _ISO9660, + _MTREE, + _SHAR, + _SHAR_BASE, + _SHAR_DUMP, + _TAR, + _TAR_GNUTAR, + _TAR_PAX_INTERCHANGE, + _TAR_PAX_RESTRICTED, + _TAR_USTAR, + _XAR, + _ZIP +}; + +} +} + +#endif // ARCHIVE_WRITER_FORMAT_HPP_INCLUDED