SourcePro® 2022.1 |
SourcePro® API Reference Guide |
Allocates and deallocates storage in a disk file, much like a "freestore" manager. More...
#include <rw/filemgr.h>
Public Member Functions | |
RWFileManager (const char *filename, const char *mode=rwnil) | |
~RWFileManager () | |
RWoffset | allocate (RWspace s) |
void | deallocate (RWoffset t) |
RWoffset | endData () const |
RWoffset | start () const |
Public Member Functions inherited from RWFile | |
RWFile (const char *filename, const char *mode=0, bool large_file=false) | |
~RWFile () | |
const char * | Access () const |
void | ClearErr () |
RWoffset | CurOffset () const |
RWoffset64 | CurOffset64 () const |
bool | Eof () const |
bool | eof () const |
bool | Erase () |
bool | Error () const |
bool | Exists () const |
bool | Flush () |
const char * | GetName () const |
FILE * | GetStream () const |
bool | good () const |
bool | IsEmpty () const |
bool | isValid () const |
bool | Read (bool &i) |
bool | Read (char &c) |
bool | Read (short &i) |
bool | Read (int &i) |
bool | Read (long &i) |
bool | Read (unsigned char &c) |
bool | Read (wchar_t &w) |
bool | Read (unsigned short &i) |
bool | Read (unsigned int &i) |
bool | Read (unsigned long &i) |
bool | Read (float &f) |
bool | Read (double &s) |
bool | Read (long long &i) |
bool | Read (unsigned long long &i) |
bool | Read (long double &d) |
bool | Read (char *i, size_t n, int delim, size_t *count=0) |
bool | Read (bool *i, size_t n, size_t *count=0) |
bool | Read (char *i, size_t n, size_t *count=0) |
bool | Read (short *i, size_t n, size_t *count=0) |
bool | Read (int *i, size_t n, size_t *count=0) |
bool | Read (long *i, size_t n, size_t *count=0) |
bool | Read (wchar_t *i, size_t n, size_t *count=0) |
bool | Read (unsigned char *c, size_t n, size_t *count=0) |
bool | Read (unsigned short *i, size_t n, size_t *count=0) |
bool | Read (unsigned int *i, size_t n, size_t *count=0) |
bool | Read (unsigned long *i, size_t n, size_t *count=0) |
bool | Read (float *i, size_t n, size_t *count=0) |
bool | Read (double *i, size_t n, size_t *count=0) |
bool | Read (long long *i, size_t n, size_t *count=0) |
bool | Read (unsigned long long *i, size_t n, size_t *count=0) |
bool | Read (long double *i, size_t n, size_t *count=0) |
bool | Read (char *string) |
bool | SeekTo (RWoffset offset) |
bool | SeekTo64 (RWoffset64 offset) |
bool | SeekToBegin () |
bool | SeekToEnd () |
bool | Write (bool i) |
bool | Write (char i) |
bool | Write (short i) |
bool | Write (int i) |
bool | Write (long i) |
bool | Write (wchar_t i) |
bool | Write (unsigned char i) |
bool | Write (unsigned short i) |
bool | Write (unsigned int i) |
bool | Write (unsigned long i) |
bool | Write (float f) |
bool | Write (double d) |
bool | Write (long long i) |
bool | Write (unsigned long long i) |
bool | Write (long double d) |
bool | Write (const char *string) |
bool | Write (const bool *i, size_t count) |
bool | Write (const short *i, size_t count) |
bool | Write (const int *i, size_t count) |
bool | Write (const long *i, size_t count) |
bool | Write (const wchar_t *i, size_t count) |
bool | Write (const unsigned char *c, size_t N) |
bool | Write (const unsigned short *i, size_t N) |
bool | Write (const unsigned int *i, size_t N) |
bool | Write (const unsigned long *i, size_t N) |
bool | Write (const float *i, size_t count) |
bool | Write (const double *i, size_t count) |
bool | Write (const char *string, size_t) |
bool | Write (const long long *i, size_t count) |
bool | Write (const unsigned long long *i, size_t count) |
bool | Write (const long double *i, size_t count) |
Additional Inherited Members | |
Static Public Member Functions inherited from RWFile | |
static bool | Exists (const char *filename) |
static bool | Exists (const char *filename, int mode) |
Class RWFileManager allocates and deallocates storage in a disk file, much like a "freestore" manager. It does this by maintaining a linked list of free space within the file.
If a file is managed by an RWFileManager, then reading or writing to unallocated space in the file has undefined results. In particular, overwriting the end of allocated space is a common problem which usually results in corrupted data. One way to encounter this problem is to use binaryStoreSize() to discover the amount of space needed to store an RWCollection. For most purposes, the storage size of an RWCollection is found using the RWCollectable method recursiveStoreSize().
RWFileManager::RWFileManager | ( | const char * | filename, |
const char * | mode = rwnil |
||
) |
Constructs an RWFileManager for the file with path name filename using mode mode. The mode is as given by the C Standard Library function fopen(). If mode is zero (the default), then the constructor attempts to open an existing file with the given filename for update (mode "rb+"
). If this is not possible, then it attempts to create a new file with the given filename (mode "wb+"
). If the file exists and is not empty, then the constructor assumes it contains an existing file manager; other contents cause the function to throw an exception of type RWExternalErr. If no file exists or if an existing file is empty, then the constructor attempts to create the file (if necessary) and initialize it with a new file manager. The resultant object should be checked for validity using function isValid(). RWFileErr is a possible exception that could be thrown.
RWFileManager::~RWFileManager | ( | ) |
Empty Destructor.
RWoffset RWFileManager::allocate | ( | RWspace | s | ) |
void RWFileManager::deallocate | ( | RWoffset | t | ) |
Deallocates (frees) the storage space starting at offset t. This space must have been previously allocated by a call to allocate(). The very first allocation ever made in the file is considered "special" and cannot be deallocated. RWFileErr is a possible exception that could be thrown.
|
inline |
Returns an offset just past the end of the file.
Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |