nn::fs::FileStream Class

Syntax

class FileStream : 
    private nn::fs::IStream,
    private nn::fs::detail::FileBase,
    private ADLFireWall::NonCopyable

Description

Class for reading from and writing to files.

Can open the file specified by a path name and read and write data from and to it.

You can specify path names using both wide strings and multibyte strings. If you specify a multibyte string, a buffer for conversion to wide characters will be allocated on the stack. You should use a wide string unless you have a specific reason not to.

This class cannot be used to create new files in expanded save data. For that, use a TryCreateFile function that specifies the size.

Limitations

When reading from (or writing to) a file, performance will degrade enormously if the read position (or write position) and buffer alignment do not match.
We recommend reading from (or writing to) files in multiples of four bytes, and aligning your buffer on a multiple of four bytes as well.

Member Functions

FileStream Constructor.
Initialize Opens the specified file.
TryInitialize Opens the specified file.
Finalize Closes a file.
V ~FileStream Destructor.
V Read Loads the specified amount of data from a file into a buffer.
V TryRead Loads the specified amount of data from a file into a buffer.
V Write Writes the specified amount of data from a buffer to a file.
V TryWrite Writes the specified amount of data from a buffer to a file.
V Seek Changes the read/write position in a file.
V TrySeek Changes the read position of a file.
V GetPosition Gets the current read position relative to the start of the file.
V TryGetPosition Gets the current read position relative to the start of the file.
V SetPosition Sets the current read position relative to the start of the file.
V TrySetPosition Sets the current read position relative to the start of the file.
V GetSize Gets the file size.
V TryGetSize Gets the file size.
V SetSize Sets the file size.
V TrySetSize Sets the file size.
V Flush Writes the file cache back to the device.
V TryFlush Writes the file cache back to the device.

Class Hierarchy

nn::fs::IPositionable
  nn::fs::IInputStream
    nn::fs::IStream
      nn::fs::FileStream

Revision History

2011/03/14
Added note about limitation of read position (or write position) and buffer alignment.
2010/01/29
Initial version.

CONFIDENTIAL