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

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# FUFile Class Reference
[Utility Classes.]

A cross-platform file. More...

`#include <FUFile.h>`

List of all members.

## Public Types
enum | Mode { READ, WRITE }
| The file open mode. More...
## Public Member Functions
| FUFile (const fstring &filename, Mode mode)
| Constructor.
| FUFile (const fchar *filename, Mode mode)
| See above.
| FUFile ()
| Default constructor.
| ~FUFile ()
| Destructor.
const fstring & | GetFilePath () const
| Retrieves the absolute, OS-specific path used to open this file.
bool | Open (const fstring &filename, Mode mode)
| Opens a file on the file system.
bool | Open (const fchar *filename, Mode mode)
| See above.
bool | IsOpen ()
| Retrieves whether a file is attached to this object.
size_t | GetLength ()
| Retrieves the length, in bytes, of the attached file.
FILE * | GetHandle ()
bool | Read (void *buffer, size_t length)
| Reads length bytes of data from this file.
bool | Write (const void *buffer, size_t length)
| Writes length bytes of data to this file.
void | Flush ()
| Flushes the data written to the file.
void | Close ()
| Closes and detaches the file.

## Detailed Description

A cross-platform file.

This class encapsulates synchronous file I/O across different platforms and supports Unicode where the platform does.

## Member Enumeration Documentation

enum FUFile::Mode

  | The file open mode. Enumerator:
  READ | Open for reading only.
  WRITE | Open for writing only.

## Constructor & Destructor Documentation

FUFile::FUFile | ( | const fstring & | filename,
|  | Mode | mode
| ) |

  | Constructor. Parameters:
  | filename | The filename of the file to open.
  | mode | The opening mode.

FUFile::FUFile | ( |  | ) |

| Default constructor. The file object will not be attached: use the Open function to attach the file object to a file on the file system.

FUFile::~FUFile | ( |  | ) |

| Destructor. Automatically flushes/closes any file left opened.

## Member Function Documentation

void FUFile::Flush | ( |  | ) |

| Flushes the data written to the file. This function will do nothing if the file was not opened in WRITE mode.

const fstring& FUFile::GetFilePath | ( |  | ) | const`[inline]`

| Retrieves the absolute, OS-specific path used to open this file. Returns: The path.

FILE* FUFile::GetHandle | ( |  | ) | `[inline]`

| Deprecated: Retrieves the OS-specific handle to the file. Using this function is not recommended. Returns: The OS-specific file handle.

size_t FUFile::GetLength | ( |  | ) |

| Retrieves the length, in bytes, of the attached file. Returns: The length of the file, in bytes.

bool FUFile::IsOpen | ( |  | ) | `[inline]`

| Retrieves whether a file is attached to this object. Returns: Whether a file is attached to this object.

bool FUFile::Open | ( | const fstring & | filename,
|  | Mode | mode
| ) | `[inline]`

  | Opens a file on the file system. Parameters:
  | filename | The filename of the file to open.
  | mode | The opening mode.
Returns: Whether the open command was successful.

bool FUFile::Read | ( | void * | buffer,
|  | size_t | length
| ) |

  | Reads length bytes of data from this file. This function will fail if the file was not opened in READ mode. This function will advance the FILE pointer length bytes ahead. Parameters:
  | buffer | A buffer large enough to accept the wanted data.
  | length | The length, in bytes, of the data to read.
Returns: True on success, false otherwise.

bool FUFile::Write | ( | const void * | buffer,
|  | size_t | length
| ) |

  | Writes length bytes of data to this file. This function will fail if the file was not opened in WRITE mode. Parameters:
  | buffer | A buffer contained the data to write.
  | length | The length, in bytes, of the data to write.
Returns: True on success, false otherwise.

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

- FUtils/FUFile.h