Class TFileSystem

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TFileSystem = class(TReferenceCounted)

Description

Manages files and archives and provides access to them.
It manages where files are, so that modules which use the the IO do not need to know where every file is located. A file could be in a .zip-Archive or as file on disk, using the TFileSystem makes no difference to this.

Hierarchy

Overview

Methods

Public function AddFileArchive(const FileName: StringType; IgnoreCase: Boolean = True; IgnorePaths: Boolean = True; ArchiveType: TFileArchiveType = faUnknown; const Password: AnsiString = ''): Boolean; inline;
Public function ChangeWorkingDirectoryTo(const NewDirecotry: StringType): Boolean; inline;
Public function CreateAndOpenFile(const FileName: StringType): TReadFile; inline;
Public function CreateAndWriteFile(const FileName: StringType; Append: Boolean = False): TWriteFile; inline;
Public function CreateEmptyAttributes(Driver: TVideoDriver = nil): TAttributes; inline;
Public function CreateEmptyFileList(const Path: StringType; IgnoreCase, IgnorePaths: Boolean): TFileList; inline;
Public function CreateFileList: TFileList; inline;
Public function CreateLimitReadFile(const FileName: StringType; AlreadyOpenedFile: TReadFile; Pos, AreaSize: LongType): TReadFile; inline;
Public function CreateMemoryReadFile(Memory: Pointer; Bytes: LongInt; const FileName: StringType; DeleteMemoryWhenDropped: Boolean = False): TReadFile; inline;
Public function CreateMemoryWriteFile(Memory: Pointer; Bytes: LongInt; const FileName: StringType; DeleteMemoryWhenDropped: Boolean = False): TWriteFile; inline;
Public function CreateXMLReader(const FileName: StringType): TXMLReader; overload; inline;
Public function CreateXMLReader(RFile: TReadFile): TXMLReader; overload; inline;
Public function CreateXMLWriter(const FileName: StringType): TXMLWriter; overload; inline;
Public function CreateXMLWriter(WFile: TWriteFile): TXMLWriter; overload; inline;
Public function FileExists(const Path: StringType): Boolean; inline;
Public function FlattenFileName(const FileName: StringType; const Root: StringType='/'): StringType; inline;
Public function GetAbsolutePath(const FileName: StringType): StringType; inline;
Public function GetFileArchive(Index: LongWord): TFileArchive; inline;
Public function GetFileBaseName(const FileName: StringType; KeepExtension: Boolean = True): StringType; inline;
Public function GetFileDir(const FileName: StringType): StringType; inline;
Public function MoveFileArchive(Index: LongWord; Relative: LongInt): Boolean; inline;
Public function RemoveFileArchive(Index: LongWord): Boolean; overload; inline;
Public function RemoveFileArchive(const FileName: StringType): Boolean; overload; inline;
Public function SetFileListSystem(ListType: TFileSystemType): TFileSystemType; inline;
Public procedure AddArchiveLoader(Loader: TArchiveLoader); inline;

Properties

Public property FileArchiveCount: LongWord read GetFileArchiveCount;
Public property WorkingDirectory: StringType read GetWorkingDirectory;

Description

Methods

Public function AddFileArchive(const FileName: StringType; IgnoreCase: Boolean = True; IgnorePaths: Boolean = True; ArchiveType: TFileArchiveType = faUnknown; const Password: AnsiString = ''): Boolean; inline;

Adds an archive to the file system.
After calling this, the Irrlicht Engine will also search and open files directly from this archive. This is useful for hiding data from the end user, speeding up file access and making it possible to access for example Quake3 .pk3 files, which are just renamed .zip files. By default Irrlicht supports ZIP, PAK, TAR, PNK, and directories as archives. You can provide your own archive types by implementing IArchiveLoader and passing an instance to addArchiveLoader. Irrlicht supports AES-encrypted zip files, and the advanced compression techniques lzma and bzip2.

Parameters
Filename
of the archive to add to the file system.
IgnoreCase
If set to true, files in the archive can be accessed without writing all letters in the right case.
IgnorePaths
If set to true, files in the added archive can be accessed without its complete path.
ArchiveType
If no specific TFileArchiveType is selected, the type of archive will depend on the extension of the file name. If you use a different extension then you can use this parameter to force a specific type of archive.
Password
An optional password, which is used in case of encrypted archives.
Returns

True if the archive was added successfully, false if not.

Public function ChangeWorkingDirectoryTo(const NewDirecotry: StringType): Boolean; inline;

Changes the current working directory.

Parameters
NewDirectory
A string specifying the new working directory. The string is operating system dependent. Under Windows it has the form "<drive>:\<directory>\<sudirectory>\<..>". An example would be: "C:\Windows\".
Returns

True if successful, otherwise false.

Public function CreateAndOpenFile(const FileName: StringType): TReadFile; inline;

Opens a file for read access.

Parameters
FileName
Name of file to open.
Returns

The created file interface. The returned pointer should be dropped when no longer needed. See TReferenceCounted.Drop for more information.

Public function CreateAndWriteFile(const FileName: StringType; Append: Boolean = False): TWriteFile; inline;

Opens a file for write access.

Parameters
FileName
Name of file to open.
Append
If the file already exists, all write operations are appended to the file.
Returns

The created file interface. The returned pointer should be dropped when no longer needed. See TReferenceCounted.Drop for more information.

Public function CreateEmptyAttributes(Driver: TVideoDriver = nil): TAttributes; inline;

Creates a new empty collection of attributes, usable for serialization and more.

Parameters
Driver
Video driver to be used to load textures when specified as attribute values. Can be null to prevent automatic texture loading by attributes.
Returns

The created object. Should be dropped when no longer needed, see TReferenceCounted.Drop for more information.

Public function CreateEmptyFileList(const Path: StringType; IgnoreCase, IgnorePaths: Boolean): TFileList; inline;

Creates a new empty collection of attributes, usable for serialization and more.

Parameters
Driver
Video driver to be used to load textures when specified as attribute values. Can be null to prevent automatic texture loading by attributes.
Returns

The created object. Should be dropped when no longer needed, see TReferenceCounted.Drop for more information.

Public function CreateFileList: TFileList; inline;

Creates an empty file list.

Returns

The created object. Should be dropped when no longer needed, see TReferenceCounted.Drop for more information.

Public function CreateLimitReadFile(const FileName: StringType; AlreadyOpenedFile: TReadFile; Pos, AreaSize: LongType): TReadFile; inline;

Creates a TReadFile interface for accessing files inside files.
This is useful e.g. for archives.

Parameters
FileName
The name given to this file.
AlreadyOpenedFile
Pointer to the enclosing file.
Pos
Start of the file inside alreadyOpenedFile.
AreaSize
The length of the file.
Returns

The created object. Should be dropped when no longer needed, see TReferenceCounted.Drop for more information.

Public function CreateMemoryReadFile(Memory: Pointer; Bytes: LongInt; const FileName: StringType; DeleteMemoryWhenDropped: Boolean = False): TReadFile; inline;

Creates a TReadFile interface for accessing memory like a file.
This allows you to use a pointer to memory where an IReadFile is requested.

Parameters
Memory
A pointer to the start of the file in memory
Bytes
The length of the memory in bytes
FileName
The name given to this file
DeleteMemoryWhenDropped
True if the memory should be deleted along with the TReadFile when it is dropped.
Returns

The created object. Should be dropped when no longer needed, see TReferenceCounted.Drop for more information.

Public function CreateMemoryWriteFile(Memory: Pointer; Bytes: LongInt; const FileName: StringType; DeleteMemoryWhenDropped: Boolean = False): TWriteFile; inline;

Creates a TWriteFile interface for accessing memory like a file.
This allows you to use a pointer to memory where an IWriteFile is requested. You are responsible for allocating enough memory.

Parameters
Memory
A pointer to the start of the file in memory (allocated by you)
Bytes
The length of the memory in bytes
FileName
The name given to this file
DeleteMemoryWhenDropped
True if the memory should be deleted along with the TWriteFile when it is dropped.
Returns

The created object. Should be dropped when no longer needed, see TReferenceCounted.Drop for more information.

Public function CreateXMLReader(const FileName: StringType): TXMLReader; overload; inline;

Creates a XML reader by file name.

Returns

nil, if file could not be opened, otherwise a pointer to the created TXMLReader is returned. After use, the reader has to be deleted using its TXMLReader.Drop method. See TReferenceCounted,Drop for more information.

Public function CreateXMLReader(RFile: TReadFile): TXMLReader; overload; inline;

Creates a XML reader from an open TReadFile.

Returns

nil, if file could not be opened, otherwise a pointer to the created TXMLReader is returned. After use, the reader has to be deleted using its TXMLReader.Drop method. See TReferenceCounted,Drop for more information.

Public function CreateXMLWriter(const FileName: StringType): TXMLWriter; overload; inline;

Creates a XML writer writing to a newly opened file.

Returns

nil, if file could not be opened, otherwise a pointer to the created TXMLReader is returned. After use, the reader has to be deleted using its TXMLReader.Drop method. See TReferenceCounted,Drop for more information.

Public function CreateXMLWriter(WFile: TWriteFile): TXMLWriter; overload; inline;

Creates a XML writer on an open TWriteFile.

Returns

nil, if file could not be opened, otherwise a pointer to the created TXMLReader is returned. After use, the reader has to be deleted using its TXMLReader.Drop method. See TReferenceCounted,Drop for more information.

Public function FileExists(const Path: StringType): Boolean; inline;

Determines if a file exists and could be opened.

Parameters
Path
the string identifying the file which should be tested for existence.
Returns

True if file exists, and false if it does not exist or an error occured.

Public function FlattenFileName(const FileName: StringType; const Root: StringType='/'): StringType; inline;

Flattens a path and file name.
For example: "/you/me/../." becomes "/you".

Public function GetAbsolutePath(const FileName: StringType): StringType; inline;

Converts a relative path to an absolute (unique) path resolving symbolic links if required.

Parameters
FileName
Possibly relative file or directory name to query.
Returns

Absolute filename which points to the same file.

Public function GetFileArchive(Index: LongWord): TFileArchive; inline;

Get the archive at a given index.

Public function GetFileBaseName(const FileName: StringType; KeepExtension: Boolean = True): StringType; inline;

Get the base part of a filename, i.e. the name without the directory part.
If no directory is prefixed, the full name is returned.

Parameters
FileName
The file to get the basename from
KeepExtension
True if filename with extension is returned otherwise everything after the final '.' is removed as well.
Public function GetFileDir(const FileName: StringType): StringType; inline;

Get the directory a file is located in.

Parameters
FileName
The file to get the directory from.
Returns

String containing the directory of the file.

Public function MoveFileArchive(Index: LongWord; Relative: LongInt): Boolean; inline;

Changes the search order of attached archives.

Parameters
Index
The index of the archive to change
Relative
The relative change in position, archives with a lower index are searched first.
Public function RemoveFileArchive(Index: LongWord): Boolean; overload; inline;

Removes an archive from the file system.
This will close the archive and free any file handles, but will not close resources which have already been loaded and are now cached, for example textures and meshes.

Parameters
FileName
The archive of the given name will be removed
Returns

True on success, false on failure.

Public function RemoveFileArchive(const FileName: StringType): Boolean; overload; inline;

Removes an archive from the file system.
This will close the archive and free any file handles, but will not close resources which have already been loaded and are now cached, for example textures and meshes.

Parameters
FileName
The archive of the given name will be removed
Returns

True on success, false on failure.

Public function SetFileListSystem(ListType: TFileSystemType): TFileSystemType; inline;

Set the active type of file system.

Public procedure AddArchiveLoader(Loader: TArchiveLoader); inline;

Adds an external archive loader to the engine.
Use this function to add support for new archive types to the engine, for example proprietary or encrypted file storage.

Properties

Public property FileArchiveCount: LongWord read GetFileArchiveCount;

The number of archives currently attached to the file system.

Public property WorkingDirectory: StringType read GetWorkingDirectory;

The current working directory.


Generated by PasDoc 0.12.1 on 2012-09-14 17:32:22