1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
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_FILE_LIST_H_INCLUDED__
6
#define __C_FILE_LIST_H_INCLUDED__
18
//! An entry in a list of files, can be a folder or a file.
21
//! The name of the file
22
/** If this is a file or folder in the virtual filesystem and the archive
23
was created with the ignoreCase flag then the file name will be lower case. */
26
//! The name of the file including the path
27
/** If this is a file or folder in the virtual filesystem and the archive was
28
created with the ignoreDirs flag then it will be the same as Name. */
31
//! The size of the file in bytes
34
//! The ID of the file in an archive
35
/** This is used to link the FileList entry to extra info held about this
36
file in an archive, which can hold things like data offset and CRC. */
39
//! FileOffset inside an archive
42
//! True if this is a folder, false if not.
45
//! The == operator is provided so that CFileList can slowly search the list!
46
bool operator ==(const struct SFileListEntry& other) const
48
if (IsDirectory != other.IsDirectory)
51
return FullName.equals_ignore_case(other.FullName);
54
//! The < operator is provided so that CFileList can sort and quickly search the list.
55
bool operator <(const struct SFileListEntry& other) const
57
if (IsDirectory != other.IsDirectory)
60
return FullName.lower_ignore_case(other.FullName);
65
//! Implementation of a file list
66
class CFileList : public IFileList
73
/** \param path The path of this file archive */
74
CFileList(const io::path& path, bool ignoreCase, bool ignorePaths);
79
//! Add as a file or folder to the list
80
/** \param fullPath The file name including path, up to the root of the file list.
81
\param isDirectory True if this is a directory rather than a file.
82
\param offset The offset where the file is stored in an archive
83
\param size The size of the file in bytes.
84
\param id The ID of the file in the archive which owns it */
85
virtual u32 addItem(const io::path& fullPath, u32 offset, u32 size, bool isDirectory, u32 id=0);
87
//! Sorts the file list. You should call this after adding any items to the file list
90
//! Returns the amount of files in the filelist.
91
virtual u32 getFileCount() const;
93
//! Gets the name of a file in the list, based on an index.
94
virtual const io::path& getFileName(u32 index) const;
96
//! Gets the full name of a file in the list, path included, based on an index.
97
virtual const io::path& getFullFileName(u32 index) const;
99
//! Returns the ID of a file in the file list, based on an index.
100
virtual u32 getID(u32 index) const;
102
//! Returns true if the file is a directory
103
virtual bool isDirectory(u32 index) const;
105
//! Returns the size of a file
106
virtual u32 getFileSize(u32 index) const;
108
//! Returns the offest of a file
109
virtual u32 getFileOffset(u32 index) const;
111
//! Searches for a file or folder within the list, returns the index
112
virtual s32 findFile(const io::path& filename, bool isFolder) const;
114
//! Returns the base path of the file list
115
virtual const io::path& getPath() const;
119
//! Ignore paths when adding or searching for files
122
//! Ignore case when adding or searching for files
125
//! Path to the file list
129
core::array<SFileListEntry> Files;
133
} // end namespace irr
134
} // end namespace io