iFile Struct Reference (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions
iFile Struct Reference
Virtual File System (VFS)

A replacement for FILE type in the virtual file space. More...

`#include <iutil/vfs.h>`

Inheritance diagram for iFile:

List of all members.

## Public Member Functions
virtual bool | AtEOF ()=0
| Returns true if the stream is at end-of-file, else false.
virtual void | Flush ()=0
| Flush stream.
virtual csPtr< iDataBuffer > | GetAllData (bool nullterm=false)=0
| Request whole content of the file as a single data buffer.
virtual csPtr< iDataBuffer > | GetAllData (CS::Memory::iAllocator *allocator)=0
| Request whole content of the file as a single data buffer.
virtual const char * | GetName ()=0
| Query file name (in VFS)
virtual csPtr< iFile > | GetPartialView (size_t offset, size_t size=(size_t)~0)=0
| Request whole or part of the content of the file as a file object.
virtual size_t | GetPos ()=0
| Query current file pointer.
virtual size_t | GetSize ()=0
| Query file size.
virtual int | GetStatus ()=0
| Check (and clear) file last error status.
virtual size_t | Read (char *Data, size_t DataSize)=0
| Read DataSize bytes and place them into the buffer at which Data points.
virtual bool | SetPos (size_t newpos)=0
| Set new file pointer.
virtual size_t | Write (const char *Data, size_t DataSize)=0
| Write DataSize bytes from the buffer at which Data points.

## Detailed Description

A replacement for FILE type in the virtual file space.

Main creators of instances implementing this interface:

- iVFS::Open()

Definition at line 159 of file vfs.h.

## Member Function Documentation

virtual bool iFile::AtEOF | ( |  | ) | `[pure virtual]`

Returns true if the stream is at end-of-file, else false.

Implemented in csMemFile, and csPhysicalFile.

virtual void iFile::Flush | ( |  | ) | `[pure virtual]`

Flush stream.

Implemented in csMemFile, and csPhysicalFile.

virtual csPtr<iDataBuffer> iFile::GetAllData | ( | bool | nullterm = `false` | ) | `[pure virtual]`

Request whole content of the file as a single data buffer.

Parameters:

  nullterm | Set this to true if you want a null char to be appended to the buffer (e.g. for use with string functions.)

Remarks:
  Null-termination might have a performance penalty (depending upon where the file is stored.) Use only when needed.

Returns:
  The complete data contained in the file; or an invalidated pointer if this object does not support this function (e.g. write-only VFS files). Check for an invalidated result via csRef<>::IsValid(). Do not modify the contained data!

Implemented in csPhysicalFile, and csMemFile.

virtual csPtr<iDataBuffer> iFile::GetAllData | ( | CS::Memory::iAllocator * | allocator | ) | `[pure virtual]`

Request whole content of the file as a single data buffer.

Uses the allocator allocator if memory allocations are necessary.

Returns:
  The complete data contained in the file; or an invalidated pointer if this object does not support this function (e.g. write-only VFS files). Check for an invalidated result via csRef<>::IsValid(). Do not modify the contained data!

Implemented in csPhysicalFile, and csMemFile.

virtual const char* iFile::GetName | ( |  | ) | `[pure virtual]`

Query file name (in VFS)

Implemented in csMemFile, and csPhysicalFile.

virtual csPtr<iFile> iFile::GetPartialView | ( | size_t | offset,
|  | size_t | size = `(size_t)~0`
| ) |  | `[pure virtual]`

Request whole or part of the content of the file as a file object.

Parameters:

  offset | Offset of data to return.
  size | Size of data to return. If `~0` all the data starting at offset up to the end of the file is returned.

Returns:
  A file object operating on a part of the original file.

Remarks:
  Note that the returned file will not support writing.

Implemented in csPhysicalFile, and csMemFile.

virtual size_t iFile::GetPos | ( |  | ) | `[pure virtual]`

Query current file pointer.

Implemented in csMemFile, and csPhysicalFile.

virtual size_t iFile::GetSize | ( |  | ) | `[pure virtual]`

Query file size.

Implemented in csMemFile, and csPhysicalFile.

virtual int iFile::GetStatus | ( |  | ) | `[pure virtual]`

Check (and clear) file last error status.

See also:
  VFS_STATUS_ACCESSDENIED

Implemented in csMemFile, and csPhysicalFile.

virtual size_t iFile::Read | ( | char * | Data,
|  | size_t | DataSize
| ) |  | `[pure virtual]`

Read DataSize bytes and place them into the buffer at which Data points.

Parameters:

  Data | Pointer to the buffer into which the data should be read. The buffer should be at least DataSize bytes in size.
  DataSize | Number of bytes to read.

Returns:
  The number of bytes actually read. If an error occurs, zero is returned. Invoke GetStatus() to retrieve the error code.

Implemented in csMemFile, and csPhysicalFile.

virtual bool iFile::SetPos | ( | size_t | newpos | ) | `[pure virtual]`

Set new file pointer.

Parameters:

  newpos | New position in file.

Returns:
  True if the operation succeeded, else false.

Implemented in csMemFile, and csPhysicalFile.

virtual size_t iFile::Write | ( | const char * | Data,
|  | size_t | DataSize
| ) |  | `[pure virtual]`

Write DataSize bytes from the buffer at which Data points.

Parameters:

  Data | Pointer to the data to be written.
  DataSize | Number of bytes to write.

Returns:
  The number of bytes actually written. If an error occurs, zero is returned. Invoke GetStatus() to retrieve the error code.

Implemented in csMemFile, and csPhysicalFile.

The documentation for this struct was generated from the following file:

- iutil/vfs.h