sincerely
Singaporean
If you have not done so, read this full tutorial on how to use SGEXTN to build an application.
class SGXFile;
part of SGEXTN module SG_FileSystem
file access in the form of reading and writing
list of all including inherited members
preprocessor file inclusion directive: #include ‹SGXFile.h›
CMake target for BuildLah: SGEXTN::SG_FileSystem
see this link for more information about BuildLah
parent class: (none)
children classes: (none)
enum OpenStatus { NotOpen, ReadOnly, WriteOnly, FullAccess };
SGXFile::OpenStatus openStatus;
SGXFile(const SGXString& s, SGXFile::OpenStatus openMode);
[[nodiscard]] bool canRead() const;
[[nodiscard]] bool canWrite() const;
[[nodiscard]] long long getPointerLocation() const;
[[nodiscard]] SGLArray‹char› readAllBytes() const;
[[nodiscard]] bool readBool() const;
[[nodiscard]] SGLArray‹char› readBytes(long long n) const;
[[nodiscard]] char readChar() const;
[[nodiscard]] SGXColourHSLA readColourHSLA() const;
[[nodiscard]] SGXColourRGBA readColourRGBA() const;
[[nodiscard]] double readDouble() const;
[[nodiscard]] float readFloat() const;
[[nodiscard]] SGXIdentifier readIdentifier() const;
[[nodiscard]] int readInt() const;
[[nodiscard]] long long readLongLong() const;
[[nodiscard]] SGXChar readSGEXTNChar() const;
[[nodiscard]] SGXString readString() const;
[[nodiscard]] SGXTimeStamp readTimeStamp() const;
[[nodiscard]] unsigned int readUnsignedInt() const;
[[nodiscard]] unsigned long long readUnsignedLongLong() const;
[[nodiscard]] SGXVector2 readVector2() const;
void setPointerLocation(long long x) const;
void writeBool(bool x) const;
void writeBytes(const SGLArray‹char›& x) const;
void writeChar(char x) const;
void writeColourHSLA(SGXColourHSLA x) const;
void writeColourRGBA(SGXColourRGBA x) const;
void writeDouble(double x) const;
void writeFloat(float x) const;
void writeIdentifier(SGXIdentifier x) const;
void writeInt(int x) const;
void writeLongLong(long long x) const;
void writeSGEXTNChar(SGXChar x) const;
void writeString(const SGXString& x) const;
void writeTimeStamp(SGXTimeStamp x) const;
void writeUnsignedInt(unsigned int x) const;
void writeUnsignedLongLong(unsigned long long x) const;
void writeVector2(SGXVector2 x) const;
static SGXString readAllText(const SGXString& filePath);
static void writeAllText(const SGXString& filePath, const SGXString& contents);
SGXFile provides access to the file system by mainly reading from and writing into binary files. Support for text files exist but you can only read the whole file at a time. You should use binary files to store user data. The current location of the SGXFile pointer within the file is maintained and is moved automatically when reading or writing. This pointer can also be moved manually to follow offsets provided in the file.
SGXFile wraps QFile and QDataStream with custom handling for SGEXTN structs.
Modes in which the file can be opened in. ReadOnly and FullAccess are read capable, WriteOnly and FullAccess are write capable.
Reading from the file in a non read capable mode or writing to the file in a non write capable mode will crash. Using the file in any way, including moving to a certain pointer offset, when it is in NotOpen mode will crash.
The mode that the file is currently open in.
Reading from, writing to, and modifying the pointer in a SGXFile with SGXFile::openStatus being NotOpen will crash.
Creates a SGXFile object pointing to the file at path s and attempts to open it using the mode openMode.
If the file does not exist or cannot be opened due to a file system error, its SGXFile::openStatus will be set to NotOpen.
Returns if the file is open in a read capable mode.
If this is false, reading from the file will crash.
Returns if the file is open in a write capable mode.
If this is false, writing to the file will crash.
Returns the current location of the file pointer as a byte offset from the start of the file.
If SGXFile::openStatus is NotOpen, this will crash.
Reads all data in the file as bytes.
This ignores the file pointer.
If the file is not open in a read capable mode, this will crash.
Reads a bool from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Reads n bytes at the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
This will crash if n is negative.
Reads a C++ char from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Reads a SGXColourHSLA from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Reads a SGXColourRGBA from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Reads a double precision floating point number from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Reads a floating point number from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Reads a SGXIdentifier from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Reads a int from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Reads a long long from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Reads a SGXChar from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Reads a SGXString from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Reads a SGXTimeStamp from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Reads a unsigned int from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Reads a unsigned long long from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Reads a SGXVector2 from the current position in the file.
This moves the file pointer forward.
If the file is not open in a read capable mode, this will crash.
Moves the file pointer to x bytes from the start of the file.
If x is more than the length of the file, the file will be extended as necessary.
If SGXFile::openStatus is NotOpen, this will crash.
Negative x will crash.
Writes the bool x at the current position in the file.
This moves the file pointer forward.
If the file is not open in a write capable mode, this will crash.
Writes all bytes in x at the current position in the file
This moves the file pointer forwards.
If the file is not open in a write capable mode, this will crash.
Writes the C++ char x at the current position in the file.
This moves the file pointer forward.
If the file is not open in a write capable mode, this will crash.
Writes the SGXColourHSLA x at the current position in the file.
This moves the file pointer forward.
If the file is not open in a write capable mode, this will crash.
Writes the SGXColourRGBA x at the current position in the file.
This moves the file pointer forward.
If the file is not open in a write capable mode, this will crash.
Writes the double precision floating point number x at the current position in the file.
This moves the file pointer forward.
If the file is not open in a write capable mode, this will crash.
Writes the floating point number x at the current position in the file.
This moves the file pointer forward.
If the file is not open in a write capable mode, this will crash.
Writes the SGXIdentifier x at the current position in the file.
This moves the file pointer forward.
If the file is not open in a write capable mode, this will crash.
Writes the int x at the current position in the file.
This moves the file pointer forward.
IIf the file is not open in a write capable mode, this will crash.
Writes the long long x at the current position in the file.
This moves the file pointer forward.
If the file is not open in a write capable mode, this will crash.
Writes the SGXChar x at the current position in the file.
This moves the file pointer forward.
If the file is not open in a write capable mode, this will crash.
Writes the SGXString x at the current position in the file.
This moves the file pointer forward.
If the file is not open in a write capable mode, this will crash.
Writes the SGXTimeStamp x at the current position in the file.
This moves the file pointer forward.
If the file is not open in a write capable mode, this will crash.
Writes the unsigned int x at the current position in the file.
This moves the file pointer forward.
If the file is not open in a write capable mode, this will crash.
Writes the unsigned long long x at the current position in the file.
This moves the file pointer forward.
If the file is not open in a write capable mode, this will crash.
Writes the SGXVector2 x at the current position in the file.
This moves the file pointer forward.
If the file is not open in a write capable mode, this will crash.
Reads all text in the file at filePath and returns the text as a SGXString.
You are strongly encouraged to use binary files instead for better support and simplicity.
If filePath cannot be opened in a read only mode, this returns an empty string.
Overwrite the contents of the file at filePath with contents.
You are strongly encouraged to use binary files instead for better support and simplicity.
If filePath cannot be opened in a write only mode, this does nothing.
This irreversibly overwrites all data previously stored in the file.
©2025 05524F.sg (Singapore)