PixelLightAPI
.
|
Class for accessing a file in the file system. More...
#include <File.h>
Public Types | |
enum | EAccess { FileRead = 1, FileWrite = 2, FileAppend = 4, FileCreate = 8, FileText = 16, FileMemBuf = 32 } |
File access flags. More... | |
enum | ESeek { SeekSet = 0, SeekCurrent, SeekEnd } |
Seek position enumerations. More... | |
Public Member Functions | |
File () | |
Constructor. | |
File (const String &sUrl, const FileAccess *pAccess=nullptr) | |
Constructor. | |
File (const Url &cUrl, const FileAccess *pAccess=nullptr) | |
Constructor. | |
File (FILE *pFile, uint32 nAccess) | |
Constructor for a standard OS stream. | |
File (handle hFile) | |
Constructor. | |
PLCORE_API | File (uint8 *pnData, uint32 nNumOfBytes, bool bCopy=true, const String &sUrl="") |
Constructor. | |
virtual | ~File () |
Destructor. | |
bool | Create (bool bAlways=false) |
Create file. | |
bool | Delete () |
Delete file. | |
PLCORE_API bool | Open (uint32 nAccess, String::EFormat nStringFormat=String::ASCII) |
Open the file for reading and/or writing. | |
void | Close () |
Close the file. | |
bool | IsMemoryBuffered () const |
Returns whether the file is memory buffered (opened with flag 'FileMemBuf') | |
bool | IsOpen () const |
Returns whether the file is open. | |
bool | IsReadable () const |
Returns whether the file is readable. | |
bool | IsWritable () const |
Returns whether the file is writable. | |
String::EFormat | GetStringFormat () const |
Returns the string encoding format to use when dealing with string functions. | |
bool | IsEof () const |
Returns whether end of file has been reached. | |
int | GetC () |
Reads a character. | |
bool | PutC (int nChar) |
Writes a character. | |
String | GetS () |
Reads a string. | |
int | PutS (const String &sString) |
Writes a string. | |
uint32 | Read (void *pBuffer, uint32 nSize, uint32 nCount) |
Reads the given number of bytes. | |
uint32 | Write (const void *pBuffer, uint32 nSize, uint32 nCount) |
Writes the given number of bytes. | |
bool | Flush () |
Flushes the file buffer. | |
bool | Seek (int32 nOffset=0, ESeek nLocation=SeekSet) |
Sets the starting position. | |
int32 | Tell () const |
Gets the current position of the file pointer. | |
uint32 | GetSize () const |
Returns the file size. | |
bool | Print (const String &sString) |
Writes a string into the file. | |
bool | PrintLn (const String &sString) |
Writes a string and a newline into the file. | |
const uint8 * | GetMemoryBuffer () const |
Returns a pointer to the buffer for memory buffered file. | |
PLCORE_API String | GetContentAsString () |
Returns the complete content of the file as string. | |
Static Public Member Functions | |
static PLCORE_API uint32 | CFileModeToAccessFlags (const String &sMode) |
Translates a given C file mode into access flags. | |
Static Public Attributes | |
static PLCORE_API File | StandardInput |
static PLCORE_API File | StandardOutput |
static PLCORE_API File | StandardError |
Class for accessing a file in the file system.
File access flags.
FileRead |
File can be read |
FileWrite |
File can be written |
FileAppend |
File will be appended |
FileCreate |
File will be created |
FileText |
File will be opened in text mode (whenever possible, don't set this flag because not each platform may support it) |
FileMemBuf |
File will be opened memory buffered (only usable for reading!) |
enum PLCore::File::ESeek |
PLCore::File::File | ( | ) | [inline] |
PLCore::File::File | ( | const String & | sUrl, |
const FileAccess * | pAccess = nullptr |
||
) | [inline] |
[in] | sUrl | URL of a file |
[in] | pAccess | Additional file access information (can be a null pointer) |
PLCore::File::File | ( | const Url & | cUrl, |
const FileAccess * | pAccess = nullptr |
||
) | [inline] |
[in] | cUrl | URL of a file |
[in] | pAccess | Additional file access information (can be a null pointer) |
PLCore::File::File | ( | FILE * | pFile, |
uint32 | nAccess | ||
) | [inline] |
Constructor for a standard OS stream.
[in] | pFile | Standard stream pointer |
[in] | nAccess | Access flags that were used to open the stream |
PLCore::File::File | ( | handle | hFile | ) | [inline] |
[in] | hFile | OS file handle |
PLCORE_API PLCore::File::File | ( | uint8 * | pnData, |
uint32 | nNumOfBytes, | ||
bool | bCopy = true , |
||
const String & | sUrl = "" |
||
) |
[in] | pnData | The file data, if a null pointer same as the standard constructor |
[in] | nNumOfBytes | Number of file data bytes, MUST be valid! |
[in] | bCopy | Copy the given data or use this one directly? Do ONLY set bCopy to 'false' if you are sure there can't go anything wrong. (data pointer MUST stay valid!) |
[in] | sUrl | URL of a file |
PLCore::File::~File | ( | ) | [inline, virtual] |
Destructor.
static PLCORE_API uint32 PLCore::File::CFileModeToAccessFlags | ( | const String & | sMode | ) | [static] |
Translates a given C file mode into access flags.
[in] | sMode | C file mode ("r", "r+", "w", "w+", "a", "a+", "t", "r+t" etc. used for e.g. "fopen") to translate |
bool PLCore::File::Create | ( | bool | bAlways = false | ) | [inline] |
Create file.
[in] | bAlways | If 'true', the file is created (and therefore overwritten) if it already exists |
bool PLCore::File::Delete | ( | ) | [inline] |
Delete file.
PLCORE_API bool PLCore::File::Open | ( | uint32 | nAccess, |
String::EFormat | nStringFormat = String::ASCII |
||
) |
Open the file for reading and/or writing.
[in] | nAccess | Access mode, combination of 'EAccess' flags |
[in] | nStringFormat | String encoding format to use when dealing with string functions (not supported by all file implementations) |
void PLCore::File::Close | ( | ) | [inline] |
Close the file.
Reimplemented from PLCore::FileObject.
bool PLCore::File::IsMemoryBuffered | ( | ) | const [inline] |
Returns whether the file is memory buffered (opened with flag 'FileMemBuf')
Returns whether the file is memory buffered (opened with flag FileMemBuf)
bool PLCore::File::IsOpen | ( | ) | const [inline] |
Returns whether the file is open.
bool PLCore::File::IsReadable | ( | ) | const [inline] |
Returns whether the file is readable.
bool PLCore::File::IsWritable | ( | ) | const [inline] |
Returns whether the file is writable.
String::EFormat PLCore::File::GetStringFormat | ( | ) | const [inline] |
Returns the string encoding format to use when dealing with string functions.
bool PLCore::File::IsEof | ( | ) | const [inline] |
Returns whether end of file has been reached.
int PLCore::File::GetC | ( | ) | [inline] |
Reads a character.
bool PLCore::File::PutC | ( | int | nChar | ) | [inline] |
Writes a character.
[in] | nChar | Character to write |
String PLCore::File::GetS | ( | ) | [inline] |
Reads a string.
int PLCore::File::PutS | ( | const String & | sString | ) | [inline] |
Writes a string.
[in] | sString | String which should be written into the file |
uint32 PLCore::File::Read | ( | void * | pBuffer, |
uint32 | nSize, | ||
uint32 | nCount | ||
) | [inline] |
Reads the given number of bytes.
[out] | pBuffer | Buffer were the data should be copied in (MUST valid and large enough!) |
[in] | nSize | Item size in bytes |
[in] | nCount | Maximum number of items to be read |
uint32 PLCore::File::Write | ( | const void * | pBuffer, |
uint32 | nSize, | ||
uint32 | nCount | ||
) | [inline] |
Writes the given number of bytes.
[in] | pBuffer | Buffer with the data which should be written into the file (MUST valid and large enough!) |
[in] | nSize | Item size in bytes |
[in] | nCount | Maximum number of items to be written |
bool PLCore::File::Flush | ( | ) | [inline] |
Flushes the file buffer.
bool PLCore::File::Seek | ( | int32 | nOffset = 0 , |
ESeek | nLocation = SeekSet |
||
) | [inline] |
Sets the starting position.
[in] | nOffset | File offset in bytes relative to the given location |
[in] | nLocation | Location |
int32 PLCore::File::Tell | ( | ) | const [inline] |
Gets the current position of the file pointer.
uint32 PLCore::File::GetSize | ( | ) | const [inline] |
Returns the file size.
bool PLCore::File::Print | ( | const String & | sString | ) | [inline] |
Writes a string into the file.
[in] | sString | String which should be written into the file |
bool PLCore::File::PrintLn | ( | const String & | sString | ) | [inline] |
Writes a string and a newline into the file.
[in] | sString | String which should be written into the file |
const uint8 * PLCore::File::GetMemoryBuffer | ( | ) | const [inline] |
Returns a pointer to the buffer for memory buffered file.
PLCORE_API String PLCore::File::GetContentAsString | ( | ) |
Returns the complete content of the file as string.
PLCORE_API File PLCore::File::StandardInput [static] |
Standard OS input stream (stdin)
PLCORE_API File PLCore::File::StandardOutput [static] |
Standard OS output stream (stdout)
PLCORE_API File PLCore::File::StandardError [static] |
Standard OS error stream (stderr)
|