1 // Copyright (C) 2009-2012 Gaz Davidson
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #ifndef __C_TAR_READER_H_INCLUDED__
\r
6 #define __C_TAR_READER_H_INCLUDED__
\r
8 #include "IrrCompileConfig.h"
\r
10 #ifdef __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_
\r
12 #include "IReferenceCounted.h"
\r
13 #include "IReadFile.h"
\r
14 #include "irrArray.h"
\r
15 #include "irrString.h"
\r
16 #include "IFileSystem.h"
\r
17 #include "CFileList.h"
\r
24 enum E_TAR_LINK_INDICATOR
\r
26 ETLI_REGULAR_FILE_OLD = 0 ,
\r
27 ETLI_REGULAR_FILE = '0',
\r
28 ETLI_LINK_TO_ARCHIVED_FILE = '1', // Hard link
\r
29 ETLI_SYMBOLIC_LINK = '2',
\r
30 ETLI_CHAR_SPECIAL_DEVICE = '3',
\r
31 ETLI_BLOCK_SPECIAL_DEVICE = '4',
\r
32 ETLI_DIRECTORY = '5',
\r
33 ETLI_FIFO_SPECIAL_FILE = '6',
\r
34 ETLI_CONTIGUOUS_FILE = '7'
\r
37 // byte-align structures
\r
38 #include "irrpack.h"
\r
47 c8 ModifiedTime[12];
\r
57 c8 FileNamePrefix[155];
\r
60 // Default alignment
\r
61 #include "irrunpack.h"
\r
63 //! Archiveloader capable of loading ZIP Archives
\r
64 class CArchiveLoaderTAR : public IArchiveLoader
\r
69 CArchiveLoaderTAR(io::IFileSystem* fs);
\r
71 //! returns true if the file maybe is able to be loaded by this class
\r
72 //! based on the file extension (e.g. ".tar")
\r
73 virtual bool isALoadableFileFormat(const io::path& filename) const _IRR_OVERRIDE_;
\r
75 //! Check if the file might be loaded by this class
\r
76 /** Check might look into the file.
\r
77 \param file File handle to check.
\r
78 \return True if file seems to be loadable. */
\r
79 virtual bool isALoadableFileFormat(io::IReadFile* file) const _IRR_OVERRIDE_;
\r
81 //! Check to see if the loader can create archives of this type.
\r
82 /** Check based on the archive type.
\r
83 \param fileType The archive type to check.
\r
84 \return True if the archile loader supports this type, false if not */
\r
85 virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const _IRR_OVERRIDE_;
\r
87 //! Creates an archive from the filename
\r
88 /** \param file File handle to check.
\r
89 \return Pointer to newly created archive, or 0 upon error. */
\r
90 virtual IFileArchive* createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const _IRR_OVERRIDE_;
\r
92 //! creates/loads an archive from the file.
\r
93 //! \return Pointer to the created archive. Returns 0 if loading failed.
\r
94 virtual io::IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const _IRR_OVERRIDE_;
\r
97 io::IFileSystem* FileSystem;
\r
102 class CTarReader : public virtual IFileArchive, virtual CFileList
\r
106 CTarReader(IReadFile* file, bool ignoreCase, bool ignorePaths);
\r
108 virtual ~CTarReader();
\r
110 //! opens a file by file name
\r
111 virtual IReadFile* createAndOpenFile(const io::path& filename) _IRR_OVERRIDE_;
\r
113 //! opens a file by index
\r
114 virtual IReadFile* createAndOpenFile(u32 index) _IRR_OVERRIDE_;
\r
116 //! returns the list of files
\r
117 virtual const IFileList* getFileList() const _IRR_OVERRIDE_;
\r
119 //! get the class Type
\r
120 virtual E_FILE_ARCHIVE_TYPE getType() const _IRR_OVERRIDE_ { return EFAT_TAR; }
\r
122 //! return the name (id) of the file Archive
\r
123 virtual const io::path& getArchiveName() const _IRR_OVERRIDE_ {return Path;}
\r
127 u32 populateFileList();
\r
132 } // end namespace io
\r
133 } // end namespace irr
\r
135 #endif // __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_
\r
136 #endif // __C_TAR_READER_H_INCLUDED__
\r