File

AppCUI::OS::File (class)

class File : public AppCUI::OS::DataObject

Public Functions

File()
~File()
bool OpenWrite(const std::filesystem::path &filePath)

Opens a file for Read/Write.

The file MUST exists. The file pointer will be set at the end of the file.

Parameters:

filePath – [in] is the full path to an existing file.

bool OpenRead(const std::filesystem::path &filePath)

Opens a file for Read.

The file MUST exists. The file pointer will be set at the begining of the file.

Parameters:

filePath – [in] is the full path to an existing file.

bool Create(const std::filesystem::path &filePath, bool overwriteExisting = true)

Creates a new file.

If the file exists and overwriteExisting parameter is set to true, it will be overwritten.

Parameters:
  • filePath – [in] is the full path to an existing file.

  • overwriteExisting – [in] - if set to true and the file exists it will overwrite the file. If set to false and a file exists, will fail to overwrite and the method will return false.

virtual uint64 GetSize() override
virtual uint64 GetCurrentPos() override
virtual bool SetSize(uint64 newSize) override
virtual bool SetCurrentPos(uint64 newPosition) override
virtual void Close() override

Public Static Functions

static Utils::Buffer ReadContent(const std::filesystem::path &path)
static bool WriteContent(const std::filesystem::path &path, Utils::BufferView buf)
static bool WriteContent(const std::filesystem::path &path, string_view text)

Protected Functions

virtual bool ReadBuffer(void *buffer, uint32 bufferSize, uint32 &bytesRead) override
virtual bool WriteBuffer(const void *buffer, uint32 bufferSize, uint32 &bytesWritten) override