diff --git a/Source/Engine/Platform/Base/FileBase.h b/Source/Engine/Platform/Base/FileBase.h index c6f76c610..5587e20a9 100644 --- a/Source/Engine/Platform/Base/FileBase.h +++ b/Source/Engine/Platform/Base/FileBase.h @@ -7,7 +7,6 @@ #include "Engine/Core/NonCopyable.h" #include "Engine/Core/Types/BaseTypes.h" #include "Engine/Core/Types/DateTime.h" -#include "Engine/Core/Collections/Array.h" class StringBuilder; template @@ -16,17 +15,51 @@ class DataContainer; /// /// Specifies how the operating system should open a file. /// -DECLARE_ENUM_FLAGS_5(FileMode, uint32, CreateAlways, 2, CreateNew, 1, OpenAlways, 4, OpenExisting, 3, TruncateExisting, 5); +enum class FileMode : uint32 +{ + // Creates a new file, only if it does not already exist. + CreateNew = 1, + // Creates a new file, always. + CreateAlways = 2, + // Opens a file, only if it exists. Fails if file doesn't exist. + OpenExisting = 3, + // Opens a file, always. + OpenAlways = 4, + // Opens a file and truncates it so that its size is zero bytes, only if it exists. Fails if file doesn't exist. + TruncateExisting = 5, +}; /// /// Defines constants for read, write, or read/write access to a file. /// -DECLARE_ENUM_FLAGS_3(FileAccess, uint32, Read, 0x80000000, Write, 0x40000000, ReadWrite, (uint32)FileAccess::Read | (uint32)FileAccess::Write); +enum class FileAccess : uint32 +{ + // Enables reading data from the file. + Read = 0x80000000, + // Enables writing data to the file. + Write = 0x40000000, + // Enables both data read and write operations on the file. + ReadWrite = Read | Write, +}; /// /// Contains constants for controlling the kind of access other objects can have to the same file. /// -DECLARE_ENUM_FLAGS_6(FileShare, uint32, Delete, 0x00000004, None, 0x00000000, Read, 0x00000001, Write, 0x00000002, ReadWrite, (uint32)FileShare::Read | (uint32)FileShare::Write, All, (uint32)FileShare::ReadWrite | (uint32)FileShare::Delete); +enum class FileShare : uint32 +{ + // Prevents any operations on the file file it's opened. + None = 0x00000000, + // Allows read operations on a file. + Read = 0x00000001, + // Allows write operations on a file. + Write = 0x00000002, + // Allows delete operations on a file. + Delete = 0x00000004, + // Allows read and write operations on a file. + ReadWrite = Read | Write, + // Allows any operations on a file. + All = ReadWrite | Delete, +}; /// /// The base class for file objects. @@ -34,7 +67,6 @@ DECLARE_ENUM_FLAGS_6(FileShare, uint32, Delete, 0x00000004, None, 0x00000000, Re class FLAXENGINE_API FileBase : public NonCopyable { public: - /// /// Finalizes an instance of the class. /// @@ -43,7 +75,6 @@ public: } public: - /// /// Reads data from a file. /// @@ -68,7 +99,6 @@ public: virtual void Close() = 0; public: - /// /// Gets size of the file (in bytes). /// @@ -100,14 +130,13 @@ public: virtual bool IsOpened() const = 0; public: - static bool ReadAllBytes(const StringView& path, byte* data, int32 length); - static bool ReadAllBytes(const StringView& path, Array& data); + static bool ReadAllBytes(const StringView& path, Array& data); static bool ReadAllBytes(const StringView& path, DataContainer& data); static bool ReadAllText(const StringView& path, String& data); static bool ReadAllText(const StringView& path, StringAnsi& data); static bool WriteAllBytes(const StringView& path, const byte* data, int32 length); - static bool WriteAllBytes(const StringView& path, const Array& data); + static bool WriteAllBytes(const StringView& path, const Array& data); static bool WriteAllText(const StringView& path, const String& data, Encoding encoding); static bool WriteAllText(const StringView& path, const StringBuilder& data, Encoding encoding); static bool WriteAllText(const StringView& path, const Char* data, int32 length, Encoding encoding); diff --git a/Source/Engine/Platform/Base/FileSystemBase.cpp b/Source/Engine/Platform/Base/FileSystemBase.cpp index f2f45a6d4..3d0c053d5 100644 --- a/Source/Engine/Platform/Base/FileSystemBase.cpp +++ b/Source/Engine/Platform/Base/FileSystemBase.cpp @@ -5,6 +5,7 @@ #include "Engine/Core/Types/Guid.h" #include "Engine/Core/Types/String.h" #include "Engine/Core/Types/StringView.h" +#include "Engine/Core/Collections/Array.h" #include "Engine/Core/Math/Math.h" #include "Engine/Engine/Globals.h"