]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CTarReader.h
Fix path issues when imported as subdirectory
[irrlicht.git] / source / Irrlicht / CTarReader.h
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
4 \r
5 #ifndef __C_TAR_READER_H_INCLUDED__\r
6 #define __C_TAR_READER_H_INCLUDED__\r
7 \r
8 #include "IrrCompileConfig.h"\r
9 \r
10 #ifdef __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_\r
11 \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
18 \r
19 namespace irr\r
20 {\r
21 namespace io\r
22 {\r
23 \r
24         enum E_TAR_LINK_INDICATOR\r
25         {\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
35         };\r
36 \r
37 // byte-align structures\r
38 #include "irrpack.h"\r
39 \r
40         struct STarHeader\r
41         {\r
42                 c8 FileName[100];\r
43                 c8 FileMode[8];\r
44                 c8 UserID[8];\r
45                 c8 GroupID[8];\r
46                 c8 Size[12];\r
47                 c8 ModifiedTime[12];\r
48                 c8 Checksum[8];\r
49                 c8 Link;\r
50                 c8 LinkName[100];\r
51                 c8 Magic[6];\r
52                 c8 USTARVersion[2];\r
53                 c8 UserName[32];\r
54                 c8 GroupName[32];\r
55                 c8 DeviceMajor[8];\r
56                 c8 DeviceMinor[8];\r
57                 c8 FileNamePrefix[155];\r
58         } PACK_STRUCT;\r
59 \r
60 // Default alignment\r
61 #include "irrunpack.h"\r
62 \r
63         //! Archiveloader capable of loading ZIP Archives\r
64         class CArchiveLoaderTAR : public IArchiveLoader\r
65         {\r
66         public:\r
67 \r
68                 //! Constructor\r
69                 CArchiveLoaderTAR(io::IFileSystem* fs);\r
70 \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
74 \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
80 \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
86 \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
91 \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
95 \r
96         private:\r
97                 io::IFileSystem* FileSystem;\r
98         };\r
99 \r
100 \r
101 \r
102         class CTarReader : public virtual IFileArchive, virtual CFileList\r
103         {\r
104         public:\r
105 \r
106                 CTarReader(IReadFile* file, bool ignoreCase, bool ignorePaths);\r
107 \r
108                 virtual ~CTarReader();\r
109 \r
110                 //! opens a file by file name\r
111                 virtual IReadFile* createAndOpenFile(const io::path& filename) _IRR_OVERRIDE_;\r
112 \r
113                 //! opens a file by index\r
114                 virtual IReadFile* createAndOpenFile(u32 index) _IRR_OVERRIDE_;\r
115 \r
116                 //! returns the list of files\r
117                 virtual const IFileList* getFileList() const _IRR_OVERRIDE_;\r
118 \r
119                 //! get the class Type\r
120                 virtual E_FILE_ARCHIVE_TYPE getType() const _IRR_OVERRIDE_ { return EFAT_TAR; }\r
121 \r
122                 //! return the name (id) of the file Archive\r
123                 virtual const io::path& getArchiveName() const  _IRR_OVERRIDE_ {return Path;}\r
124 \r
125         private:\r
126 \r
127                 u32 populateFileList();\r
128 \r
129                 IReadFile* File;\r
130         };\r
131 \r
132 } // end namespace io\r
133 } // end namespace irr\r
134 \r
135 #endif // __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_\r
136 #endif // __C_TAR_READER_H_INCLUDED__\r