11#include < odr/file.hpp>
22
3+ #include < odr/archive.hpp>
34#include < odr/document.hpp>
45#include < odr/exceptions.hpp>
56
@@ -25,12 +26,16 @@ FileMeta::FileMeta(const FileType type, const bool password_encrypted,
2526 : type{type}, password_encrypted{password_encrypted},
2627 document_meta{std::move (document_meta)} {}
2728
29+ File::File () = default ;
30+
2831File::File (std::shared_ptr<internal::abstract::File> impl)
2932 : m_impl{std::move (impl)} {}
3033
3134File::File (const std::string &path)
3235 : m_impl{std::make_shared<internal::common::DiskFile>(path)} {}
3336
37+ File::operator bool () const { return m_impl.operator bool (); }
38+
3439FileLocation File::location () const noexcept { return m_impl->location (); }
3540
3641std::size_t File::size () const { return m_impl->size (); }
@@ -82,6 +87,8 @@ DecodedFile::DecodedFile(const std::string &path, FileType as)
8287 : DecodedFile(internal::open_strategy::open_file(
8388 std::make_shared<internal::common::DiskFile>(path), as)) {}
8489
90+ DecodedFile::operator bool () const { return m_impl.operator bool (); }
91+
8592FileType DecodedFile::file_type () const noexcept {
8693 return m_impl->file_meta ().type ;
8794}
@@ -99,7 +106,7 @@ TextFile DecodedFile::text_file() const {
99106 std::dynamic_pointer_cast<internal::abstract::TextFile>(m_impl)) {
100107 return TextFile (text_file);
101108 }
102- throw NoImageFile ();
109+ throw NoTextFile ();
103110}
104111
105112ImageFile DecodedFile::image_file () const {
@@ -110,6 +117,14 @@ ImageFile DecodedFile::image_file() const {
110117 throw NoImageFile ();
111118}
112119
120+ ArchiveFile DecodedFile::archive_file () const {
121+ if (auto archive_file =
122+ std::dynamic_pointer_cast<internal::abstract::ArchiveFile>(m_impl)) {
123+ return ArchiveFile (archive_file);
124+ }
125+ throw NoArchiveFile ();
126+ }
127+
113128DocumentFile DecodedFile::document_file () const {
114129 if (auto document_file =
115130 std::dynamic_pointer_cast<internal::abstract::DocumentFile>(m_impl)) {
@@ -140,6 +155,11 @@ std::unique_ptr<std::istream> ImageFile::stream() const {
140155 return m_impl->file ()->stream ();
141156}
142157
158+ ArchiveFile::ArchiveFile (std::shared_ptr<internal::abstract::ArchiveFile> impl)
159+ : DecodedFile(impl), m_impl{std::move (impl)} {}
160+
161+ Archive ArchiveFile::archive () const { return Archive (m_impl->archive ()); }
162+
143163FileType DocumentFile::type (const std::string &path) {
144164 return DocumentFile (path).file_type ();
145165}
0 commit comments