diff options
author | David Walter Seikel | 2016-03-28 22:28:34 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-03-28 22:28:34 +1000 |
commit | 7028cbe09c688437910a25623098762bf0fa592d (patch) | |
tree | 10b5af58277d9880380c2251f109325542c4e6eb /src/others/irrlicht-1.8.1/source/Irrlicht/CNPKReader.h | |
parent | Move lemon to the src/others directory. (diff) | |
download | SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.zip SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.gz SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.bz2 SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.xz |
Move Irrlicht to src/others.
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CNPKReader.h')
-rw-r--r-- | src/others/irrlicht-1.8.1/source/Irrlicht/CNPKReader.h | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CNPKReader.h b/src/others/irrlicht-1.8.1/source/Irrlicht/CNPKReader.h new file mode 100644 index 0000000..e7792a6 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CNPKReader.h | |||
@@ -0,0 +1,128 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | ||
2 | // Copyright (C) 2009-2012 Christian Stehno | ||
3 | // This file is part of the "Irrlicht Engine". | ||
4 | // For conditions of distribution and use, see copyright notice in irrlicht.h | ||
5 | |||
6 | #ifndef __C_NPK_READER_H_INCLUDED__ | ||
7 | #define __C_NPK_READER_H_INCLUDED__ | ||
8 | |||
9 | #include "IrrCompileConfig.h" | ||
10 | |||
11 | #ifdef __IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_ | ||
12 | |||
13 | #include "IReferenceCounted.h" | ||
14 | #include "IReadFile.h" | ||
15 | #include "irrArray.h" | ||
16 | #include "irrString.h" | ||
17 | #include "IFileSystem.h" | ||
18 | #include "CFileList.h" | ||
19 | |||
20 | namespace irr | ||
21 | { | ||
22 | namespace io | ||
23 | { | ||
24 | namespace | ||
25 | { | ||
26 | //! File header containing location and size of the table of contents | ||
27 | struct SNPKHeader | ||
28 | { | ||
29 | // Don't change the order of these fields! They must match the order stored on disk. | ||
30 | c8 Tag[4]; | ||
31 | u32 Length; | ||
32 | u32 Offset; | ||
33 | }; | ||
34 | |||
35 | //! An entry in the NPK file's table of contents. | ||
36 | struct SNPKFileEntry | ||
37 | { | ||
38 | core::stringc Name; | ||
39 | u32 Offset; | ||
40 | u32 Length; | ||
41 | }; | ||
42 | } // end namespace | ||
43 | |||
44 | //! Archiveloader capable of loading Nebula Device 2 NPK Archives | ||
45 | class CArchiveLoaderNPK : public IArchiveLoader | ||
46 | { | ||
47 | public: | ||
48 | |||
49 | //! Constructor | ||
50 | CArchiveLoaderNPK(io::IFileSystem* fs); | ||
51 | |||
52 | //! returns true if the file maybe is able to be loaded by this class | ||
53 | //! based on the file extension (e.g. ".zip") | ||
54 | virtual bool isALoadableFileFormat(const io::path& filename) const; | ||
55 | |||
56 | //! Check if the file might be loaded by this class | ||
57 | /** Check might look into the file. | ||
58 | \param file File handle to check. | ||
59 | \return True if file seems to be loadable. */ | ||
60 | virtual bool isALoadableFileFormat(io::IReadFile* file) const; | ||
61 | |||
62 | //! Check to see if the loader can create archives of this type. | ||
63 | /** Check based on the archive type. | ||
64 | \param fileType The archive type to check. | ||
65 | \return True if the archile loader supports this type, false if not */ | ||
66 | virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const; | ||
67 | |||
68 | //! Creates an archive from the filename | ||
69 | /** \param file File handle to check. | ||
70 | \return Pointer to newly created archive, or 0 upon error. */ | ||
71 | virtual IFileArchive* createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const; | ||
72 | |||
73 | //! creates/loads an archive from the file. | ||
74 | //! \return Pointer to the created archive. Returns 0 if loading failed. | ||
75 | virtual io::IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const; | ||
76 | |||
77 | //! Returns the type of archive created by this loader | ||
78 | virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_NPK; } | ||
79 | |||
80 | private: | ||
81 | io::IFileSystem* FileSystem; | ||
82 | }; | ||
83 | |||
84 | |||
85 | //! reads from NPK | ||
86 | class CNPKReader : public virtual IFileArchive, virtual CFileList | ||
87 | { | ||
88 | public: | ||
89 | |||
90 | CNPKReader(IReadFile* file, bool ignoreCase, bool ignorePaths); | ||
91 | virtual ~CNPKReader(); | ||
92 | |||
93 | // file archive methods | ||
94 | |||
95 | //! return the id of the file Archive | ||
96 | virtual const io::path& getArchiveName() const | ||
97 | { | ||
98 | return File->getFileName(); | ||
99 | } | ||
100 | |||
101 | //! opens a file by file name | ||
102 | virtual IReadFile* createAndOpenFile(const io::path& filename); | ||
103 | |||
104 | //! opens a file by index | ||
105 | virtual IReadFile* createAndOpenFile(u32 index); | ||
106 | |||
107 | //! returns the list of files | ||
108 | virtual const IFileList* getFileList() const; | ||
109 | |||
110 | //! get the class Type | ||
111 | virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_NPK; } | ||
112 | |||
113 | private: | ||
114 | |||
115 | //! scans for a local header, returns false if the header is invalid | ||
116 | bool scanLocalHeader(); | ||
117 | void readString(core::stringc& name); | ||
118 | |||
119 | IReadFile* File; | ||
120 | }; | ||
121 | |||
122 | } // end namespace io | ||
123 | } // end namespace irr | ||
124 | |||
125 | #endif // __IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_ | ||
126 | |||
127 | #endif // __C_NPK_READER_H_INCLUDED__ | ||
128 | |||