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
5
#ifndef __C_TAR_READER_H_INCLUDED__
6
#define __C_TAR_READER_H_INCLUDED__
8
#include "IrrCompileConfig.h"
10
#ifdef __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_
12
#include "IReferenceCounted.h"
13
#include "IReadFile.h"
15
#include "irrString.h"
16
#include "IFileSystem.h"
17
#include "CFileList.h"
24
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
25
# pragma pack( push, packing )
28
#elif defined( __GNUC__ )
29
# define PACK_STRUCT __attribute__((packed))
31
# error compiler not supported
34
enum E_TAR_LINK_INDICATOR
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',
43
ETLI_FIFO_SPECIAL_FILE = '6',
44
ETLI_CONTIGUOUS_FILE = '7'
64
c8 FileNamePrefix[155];
69
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
70
# pragma pack( pop, packing )
75
//! Archiveloader capable of loading ZIP Archives
76
class CArchiveLoaderTAR : public IArchiveLoader
81
CArchiveLoaderTAR(io::IFileSystem* fs);
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;
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;
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;
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;
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;
109
io::IFileSystem* FileSystem;
114
class CTarReader : public virtual IFileArchive, virtual CFileList
118
CTarReader(IReadFile* file, bool ignoreCase, bool ignorePaths);
120
virtual ~CTarReader();
122
//! opens a file by file name
123
virtual IReadFile* createAndOpenFile(const io::path& filename);
125
//! opens a file by index
126
virtual IReadFile* createAndOpenFile(u32 index);
128
//! returns the list of files
129
virtual const IFileList* getFileList() const;
131
//! get the class Type
132
virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_TAR; }
136
u32 populateFileList();
141
} // end namespace io
142
} // end namespace irr
144
#endif // __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_
145
#endif // __C_TAR_READER_H_INCLUDED__