2009-01-14 04:37:51 -08:00
|
|
|
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
2007-05-20 11:03:49 -07:00
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#ifndef __C_FILE_LIST_H_INCLUDED__
|
|
|
|
#define __C_FILE_LIST_H_INCLUDED__
|
|
|
|
|
|
|
|
#include "IFileList.h"
|
|
|
|
#include "irrString.h"
|
|
|
|
#include "irrArray.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace io
|
|
|
|
{
|
|
|
|
|
|
|
|
/*!
|
|
|
|
FileSystem, which manages where files are, so that modules which
|
|
|
|
use the the io do not need to know where every file is located.
|
|
|
|
*/
|
|
|
|
class CFileList : public IFileList
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
CFileList();
|
|
|
|
|
|
|
|
//! Returns the amount of files in the filelist.
|
2008-07-17 02:07:21 -07:00
|
|
|
/** \return Amount of files and directories in the file list. */
|
2007-09-14 01:29:18 -07:00
|
|
|
virtual u32 getFileCount() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Gets the name of a file in the list, based on an index.
|
2008-07-17 02:07:21 -07:00
|
|
|
/** \param index is the zero based index of the file which name should
|
|
|
|
be returned. The index has to be smaller than the amount getFileCount() returns.
|
|
|
|
\return The file name of the file. Returns 0, if an error occured. */
|
2007-09-14 01:29:18 -07:00
|
|
|
virtual const c8* getFileName(u32 index) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Gets the full name of a file in the list, path included, based on an index.
|
2007-09-14 01:29:18 -07:00
|
|
|
virtual const c8* getFullFileName(u32 index);
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Returns of the file is a directory
|
2008-07-17 02:07:21 -07:00
|
|
|
/** \param index is the zero based index of the file which name should
|
|
|
|
be returned. The index has to be smaller than the amount getFileCount() returns.
|
|
|
|
\return True if the file is a directory, else false. */
|
2007-09-14 01:29:18 -07:00
|
|
|
virtual bool isDirectory(u32 index) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
struct FileEntry
|
|
|
|
{
|
|
|
|
core::stringc Name;
|
|
|
|
core::stringc FullName;
|
2007-09-14 01:29:18 -07:00
|
|
|
long Size;
|
2007-05-20 11:03:49 -07:00
|
|
|
bool isDirectory;
|
|
|
|
|
|
|
|
bool operator <(const struct FileEntry& other) const
|
|
|
|
{
|
|
|
|
if ( isDirectory ^ other.isDirectory )
|
|
|
|
return isDirectory;
|
|
|
|
|
|
|
|
return Name.lower_ignore_case ( other.Name );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
core::stringc Path;
|
|
|
|
core::array< FileEntry > Files;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace irr
|
|
|
|
} // end namespace io
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|