Class FileBase
The base class for file objects.
Inheritance
Assembly: FlaxEngine.dll
File: Engine/Platform/Base/FileBase.h
Syntax
public class FileBase : public NonCopyable
Constructors
~FileBase()
Methods
Close()
Close file handle
Declaration
public virtual void Close() = 0
GetLastWriteTime()
Retrieves the date and time that a file was last modified (in UTC).
Declaration
public virtual DateTime GetLastWriteTime() const = 0
Returns
DateTime
Last file write time. |
GetPosition()
Gets current position of the file pointer.
Declaration
public virtual uint32 GetPosition() const = 0
Returns
uint32
File pointer position. |
GetSize()
Gets size of the file (in bytes).
Declaration
public virtual uint32 GetSize() const = 0
Returns
uint32
File size in bytes. |
IsOpened()
Returns true if file is opened.
Declaration
public virtual bool IsOpened() const = 0
Returns
bool
True if file is opened, otherwise false. |
Read(void* buffer, uint32 bytesToRead, uint32* bytesRead=nullptr)
Reads data from a file.
Declaration
public virtual bool Read(void* buffer, uint32 bytesToRead, uint32* bytesRead=nullptr) = 0
Parameters
void
buffer
Output buffer to read data to it. |
uint32
bytesToRead
The maximum amount bytes to read. |
uint32
bytesRead
A pointer to the variable that receives the number of bytes read. |
Returns
bool
True if cannot read data, otherwise false. |
ReadAllBytes(const StringView& path, Array<byte, HeapAllocation>& data)
Declaration
public static bool ReadAllBytes(const StringView& path, Array<byte, HeapAllocation>& data)
Parameters
StringView
path
|
Array<byte, HeapAllocation>
data
|
Returns
bool
|
ReadAllBytes(const StringView& path, byte* data, int32 length)
Declaration
public static bool ReadAllBytes(const StringView& path, byte* data, int32 length)
Parameters
StringView
path
|
byte
data
|
int32
length
|
Returns
bool
|
ReadAllBytes(const StringView& path, DataContainer<byte>& data)
Declaration
public static bool ReadAllBytes(const StringView& path, DataContainer<byte>& data)
Parameters
StringView
path
|
DataContainer<byte>
data
|
Returns
bool
|
ReadAllText(const StringView& path, String& data)
Declaration
public static bool ReadAllText(const StringView& path, String& data)
Parameters
StringView
path
|
String
data
|
Returns
bool
|
ReadAllText(const StringView& path, StringAnsi& data)
Declaration
public static bool ReadAllText(const StringView& path, StringAnsi& data)
Parameters
StringView
path
|
StringAnsi
data
|
Returns
bool
|
SetPosition(uint32 seek)
Sets new position of the file pointer.
Declaration
public virtual void SetPosition(uint32 seek) = 0
Parameters
uint32
seek
New file pointer position. |
Write(const void* buffer, uint32 bytesToWrite, uint32* bytesWritten=nullptr)
Writes data to a file.
Declaration
public virtual bool Write(const void* buffer, uint32 bytesToWrite, uint32* bytesWritten=nullptr) = 0
Parameters
void
buffer
Output buffer to read data to it. |
uint32
bytesToWrite
The maximum amount bytes to be written. |
uint32
bytesWritten
A pointer to the variable that receives the number of bytes written. |
Returns
bool
True if cannot write data, otherwise false. |
WriteAllBytes(const StringView& path, const Array<byte, HeapAllocation>& data)
Declaration
public static bool WriteAllBytes(const StringView& path, const Array<byte, HeapAllocation>& data)
Parameters
StringView
path
|
Array<byte, HeapAllocation>
data
|
Returns
bool
|
WriteAllBytes(const StringView& path, const byte* data, int32 length)
Declaration
public static bool WriteAllBytes(const StringView& path, const byte* data, int32 length)
Parameters
StringView
path
|
byte
data
|
int32
length
|
Returns
bool
|
WriteAllText(const StringView& path, const Char* data, int32 length, Encoding encoding)
Declaration
public static bool WriteAllText(const StringView& path, const Char* data, int32 length, Encoding encoding)
Parameters
StringView
path
|
Char
data
|
int32
length
|
Encoding
encoding
|
Returns
bool
|
WriteAllText(const StringView& path, const String& data, Encoding encoding)
Declaration
public static bool WriteAllText(const StringView& path, const String& data, Encoding encoding)
Parameters
StringView
path
|
String
data
|
Encoding
encoding
|
Returns
bool
|
WriteAllText(const StringView& path, const StringBuilder& data, Encoding encoding)
Declaration
public static bool WriteAllText(const StringView& path, const StringBuilder& data, Encoding encoding)
Parameters
StringView
path
|
StringBuilder
data
|
Encoding
encoding
|
Returns
bool
|