72 bool IsEOF(
void)
const;
75 int Read(
void * a_Buffer,
size_t a_NumBytes);
78 std::basic_string<std::byte>
Read(
size_t a_NumBytes);
81 int Write(
const void * a_Buffer,
size_t a_NumBytes);
83 int Write(std::string_view a_String)
85 return Write(a_String.data(), a_String.size());
89 long Seek (
int iPosition);
92 long Tell (
void)
const;
183 template <
class StreamType>
189 FileStream(
const std::string & Path,
const typename FileStream::openmode
Mode);
200 #pragma clang diagnostic push
201 #pragma clang diagnostic ignored "-Wweak-template-vtables"
208 #pragma clang diagnostic pop
std::vector< AString > AStringVector
static bool CreateFolderRecursive(const AString &a_FolderPath)
Creates a new folder with the specified name, creating its parents if needed.
static AString GetExecutableExt()
Returns the customary executable extension used by the current platform.
static bool IsFolder(const AString &a_Path)
Returns true if the specified path is a folder.
int Write(std::string_view a_String)
int Read(void *a_Buffer, size_t a_NumBytes)
Reads up to a_NumBytes bytes into a_Buffer, returns the number of bytes actually read,...
static unsigned GetLastModificationTime(const AString &a_FileName)
Returns the last modification time (in current timezone) of the specified file.
long Seek(int iPosition)
Seeks to iPosition bytes from file start, returns old position or -1 for failure; asserts if not open...
static bool DeleteFile(const AString &a_FileName)
Deletes a file, returns true if successful.
static AString ChangeFileExt(const AString &a_FileName, const AString &a_NewExt)
Returns a_FileName with its extension changed to a_NewExt.
static bool Delete(const AString &a_Path)
Deletes a file or a folder, returns true if successful.
void Flush()
Flushes all the bufferef output into the file (only when writing)
static bool CreateFolder(const AString &a_FolderPath)
Creates a new folder with the specified name.
static bool Copy(const AString &a_SrcFileName, const AString &a_DstFileName)
Copies a file, returns true if successful.
static AString GetPathSeparator()
Returns the path separator used by the current platform.
static char PathSeparator()
static bool Rename(const AString &a_OrigPath, const AString &a_NewPath)
Renames a file or folder, returns true if successful.
eMode
The mode in which to open the file.
cFile(void)
Simple constructor - creates an unopened file object, use Open() to open / create a real file.
static bool Exists(const AString &a_FileName)
Returns true if the file specified exists.
bool Open(const AString &iFileName, eMode iMode)
static AString ReadWholeFile(const AString &a_FileName)
Returns the entire contents of the specified file as a string.
static AStringVector GetFolderContents(const AString &a_Folder)
Returns the list of all items in the specified folder (files, folders, nix pipes, whatever's there).
~cFile()
Auto-closes the file, if open.
long GetSize(void) const
Returns the size of file, in bytes, or -1 for failure; asserts if not open.
static bool DeleteFolderContents(const AString &a_FolderName)
Deletes all content from the specified folder.
int ReadRestOfFile(AString &a_Contents)
Reads the file from current position till EOF into an AString; returns the number of bytes read or -1...
long Tell(void) const
Returns the current position (bytes from file start) or -1 for failure; asserts if not open.
int Write(const void *a_Buffer, size_t a_NumBytes)
Writes up to a_NumBytes bytes from a_Buffer, returns the number of bytes actually written,...
static bool IsFile(const AString &a_Path)
Returns true if the specified path is a regular file.
static bool DeleteFolder(const AString &a_FolderName)
Deletes a folder, returns true if successful.
A wrapper for file streams that enables exceptions.
FileStream(const std::string &Path)