~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to source/Irrlicht/CTarReader.h

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2009-2011 Gaz Davidson
 
2
// This file is part of the "Irrlicht Engine".
 
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
 
4
 
 
5
#ifndef __C_TAR_READER_H_INCLUDED__
 
6
#define __C_TAR_READER_H_INCLUDED__
 
7
 
 
8
#include "IrrCompileConfig.h"
 
9
 
 
10
#ifdef __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_
 
11
 
 
12
#include "IReferenceCounted.h"
 
13
#include "IReadFile.h"
 
14
#include "irrArray.h"
 
15
#include "irrString.h"
 
16
#include "IFileSystem.h"
 
17
#include "CFileList.h"
 
18
 
 
19
namespace irr
 
20
{
 
21
namespace io
 
22
{
 
23
 
 
24
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
 
25
#       pragma pack( push, packing )
 
26
#       pragma pack( 1 )
 
27
#       define PACK_STRUCT
 
28
#elif defined( __GNUC__ )
 
29
#       define PACK_STRUCT      __attribute__((packed))
 
30
#else
 
31
#       error compiler not supported
 
32
#endif
 
33
 
 
34
        enum E_TAR_LINK_INDICATOR
 
35
        {
 
36
                ETLI_REGULAR_FILE_OLD      =  0 ,
 
37
                ETLI_REGULAR_FILE          = '0',
 
38
                ETLI_LINK_TO_ARCHIVED_FILE = '1', // Hard link
 
39
                ETLI_SYMBOLIC_LINK         = '2',
 
40
                ETLI_CHAR_SPECIAL_DEVICE   = '3',
 
41
                ETLI_BLOCK_SPECIAL_DEVICE  = '4',
 
42
                ETLI_DIRECTORY             = '5',
 
43
                ETLI_FIFO_SPECIAL_FILE     = '6',
 
44
                ETLI_CONTIGUOUS_FILE       = '7'
 
45
        };
 
46
 
 
47
        struct STarHeader
 
48
        {
 
49
                c8 FileName[100];
 
50
                c8 FileMode[8];
 
51
                c8 UserID[8];
 
52
                c8 GroupID[8];
 
53
                c8 Size[12];
 
54
                c8 ModifiedTime[12];
 
55
                c8 Checksum[8];
 
56
                c8 Link;
 
57
                c8 LinkName[100];
 
58
                c8 Magic[6];
 
59
                c8 USTARVersion[2];
 
60
                c8 UserName[32];
 
61
                c8 GroupName[32];
 
62
                c8 DeviceMajor[8];
 
63
                c8 DeviceMinor[8];
 
64
                c8 FileNamePrefix[155];
 
65
        } PACK_STRUCT;
 
66
 
 
67
 
 
68
// Default alignment
 
69
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
 
70
#       pragma pack( pop, packing )
 
71
#endif
 
72
 
 
73
#undef PACK_STRUCT
 
74
 
 
75
        //! Archiveloader capable of loading ZIP Archives
 
76
        class CArchiveLoaderTAR : public IArchiveLoader
 
77
        {
 
78
        public:
 
79
 
 
80
                //! Constructor
 
81
                CArchiveLoaderTAR(io::IFileSystem* fs);
 
82
 
 
83
                //! returns true if the file maybe is able to be loaded by this class
 
84
                //! based on the file extension (e.g. ".tar")
 
85
                virtual bool isALoadableFileFormat(const io::path& filename) const;
 
86
 
 
87
                //! Check if the file might be loaded by this class
 
88
                /** Check might look into the file.
 
89
                \param file File handle to check.
 
90
                \return True if file seems to be loadable. */
 
91
                virtual bool isALoadableFileFormat(io::IReadFile* file) const;
 
92
 
 
93
                //! Check to see if the loader can create archives of this type.
 
94
                /** Check based on the archive type.
 
95
                \param fileType The archive type to check.
 
96
                \return True if the archile loader supports this type, false if not */
 
97
                virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const;
 
98
 
 
99
                //! Creates an archive from the filename
 
100
                /** \param file File handle to check.
 
101
                \return Pointer to newly created archive, or 0 upon error. */
 
102
                virtual IFileArchive* createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const;
 
103
 
 
104
                //! creates/loads an archive from the file.
 
105
                //! \return Pointer to the created archive. Returns 0 if loading failed.
 
106
                virtual io::IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const;
 
107
 
 
108
        private:
 
109
                io::IFileSystem* FileSystem;
 
110
        };
 
111
 
 
112
 
 
113
 
 
114
        class CTarReader : public virtual IFileArchive, virtual CFileList
 
115
        {
 
116
        public:
 
117
 
 
118
                CTarReader(IReadFile* file, bool ignoreCase, bool ignorePaths);
 
119
 
 
120
                virtual ~CTarReader();
 
121
 
 
122
                //! opens a file by file name
 
123
                virtual IReadFile* createAndOpenFile(const io::path& filename);
 
124
 
 
125
                //! opens a file by index
 
126
                virtual IReadFile* createAndOpenFile(u32 index);
 
127
 
 
128
                //! returns the list of files
 
129
                virtual const IFileList* getFileList() const;
 
130
 
 
131
                //! get the class Type
 
132
                virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_TAR; }
 
133
 
 
134
        private:
 
135
 
 
136
                u32 populateFileList();
 
137
 
 
138
                IReadFile* File;
 
139
        };
 
140
 
 
141
} // end namespace io
 
142
} // end namespace irr
 
143
 
 
144
#endif // __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_
 
145
#endif // __C_TAR_READER_H_INCLUDED__