rcolyer.net
RC Lib  Version 202403231100
Public Member Functions | List of all members
RC::FileBase Class Reference

Provides the common methods for the FileRead/FileWrite/FileRW classes. More...

#include <File.h>

Inheritance diagram for RC::FileBase:
RC::FileRead RC::FileWrite RC::FileRW RC::FileRW

Public Member Functions

 FileBase ()
 Default constructor.
 
 FileBase (const FileBase &other)
 Copy constructor.
 
FileBaseoperator= (const FileBase &other)
 Assignment operator.
 
virtual ~FileBase ()
 Flushes the write buffer before destructing. This will close the file if it is the last FileBase sharing it.
 
RStr GetFilename () const
 Returns the filename if one was given upon opening.
 
void SetFilename (const RStr &newfilename) const
 Manually changes the associated filename.
 
void Close ()
 Flushes the buffers and closes the file.
 
bool IsOpen () const
 True if the file is open.
 
bool IsClosed () const
 True if the file is closed.
 
bool IsReadable () const
 True if the file is open and readable.
 
bool IsWritable () const
 True if the file is open and writable.
 
FILE * Raw () const
 Returns a raw FILE* which can be used with the C file functions.
 
void Assert () const
 Throws ErrorMsgFile if the file is closed.
 
size_t Size () const
 Returns the file size in bytes.
 
void SetPosition (const size_t pos)
 Sets the reading and writing position to pos bytes into the file.
 
void RelativePosition (const i64 amnt)
 Sets the position for the next read or write operation. More...
 
size_t GetPosition (bool quiet_fail=false) const
 Gets the position for the next read or write operation. More...
 
void Rewind ()
 Clears the read-ahead buffer used by FileRead::Get calls.
 
void Flush ()
 Flushes all unsaved data to the storage system.
 
void ClearBuffer ()
 Processes the remaining data in the Put/Get buffer.
 

Detailed Description

Provides the common methods for the FileRead/FileWrite/FileRW classes.

Member Function Documentation

◆ GetPosition()

size_t RC::FileBase::GetPosition ( bool  quiet_fail = false) const
inline

Gets the position for the next read or write operation.

Parameters
quiet_failIf true, does not throw an error from being unable to find the position. (0 is returned.)

◆ RelativePosition()

void RC::FileBase::RelativePosition ( const i64  amnt)
inline

Sets the position for the next read or write operation.

Note: This has no effect on write operations in APPEND mode.


The documentation for this class was generated from the following file:
email address
— (c) 2015