CyberEngineMkIII
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CYBFile.cpp
Go to the documentation of this file.
1 #include "CYB.hpp"
3 
4 CYB::Platform::System::File::File(const API::Path& APath, const Mode AMode, const Method AMethod) :
5  File(System::Path(static_cast<const System::Path&>(APath)), AMode, AMethod)
6 {
7  using namespace API::String;
8  Dynamic Message(u8"Opened file: ");
9  Message += APath();
10  Message += Static(" in mode: ");
11  switch (AMode) {
12  case Mode::READ:
13  Message += Static("READ");
14  break;
15  case Mode::WRITE:
16  Message += Static("WRITE");
17  break;
18  case Mode::READ_WRITE:
19  Message += Static("READ_WRITE");
20  break;
21  default:
23  }
24  Message += Static(" with method: ");
25  switch (AMethod) {
26  case Method::ANY:
27  Message += Static("ANY");
28  break;
29  case Method::CREATE:
30  Message += Static("CREATE");
31  break;
32  case Method::EXIST:
33  Message += Static("EXIST");
34  break;
35  case Method::TRUNCATE:
36  Message += Static("TRUNCATE");
37  break;
38  default:
40  }
42 }
43 
45  File(std::move(APath), Mode::WRITE, Method::ANY);
46 }
47 
49  Close();
50 }
51 
52 void CYB::Platform::System::File::Capabilities(Mode& AMode, bool& ASeek) const noexcept {
53  ASeek = true;
54  AMode = FOpenMode;
55 }
56 
57 unsigned long long CYB::Platform::System::File::CursorPosition(void) const noexcept {
58  return Seek(0, SeekLocation::CURSOR);
59 }
60 
62  return FPath;
63 }
64 
66  return FOpenMethod;
67 }
API::Interop::Context & Context(void) noexcept
Get the API's Context.
File() noexcept=default
See Default Constructors and Destructor.
static void Touch(System::Path &&APath)
Equivalent to the statement File(APath, Mode::WRITE, Method::ANY);. Opens/creates a File and updates ...
Definition: CYBFile.cpp:44
Method
The method of handling Files that already exist.
Definition: File.hpp:8
virtual void Log(const String::CStyle &AMessage, const Level ALevel)=0
Log a message. Will be written to a text file on the Path returned by CurrentLog. ...
System::Path FPath
The Path indicating this File.
Definition: CYBFile.hpp:8
Method OpenMethod(void) const noexceptfinaloverride
Gets the opening method of the File. Will never be Method::ANY.
Definition: CYBFile.cpp:65
Mode
The available operations for the Stream. Bitset.
Definition: Stream.hpp:10
The File must not exist. It will be created.
Contains the basic File interface. Does not perform locking of any kind, be aware of possible race co...
Definition: CYBFile.hpp:6
void Close(void) const noexcept
Closes the file's handle if it is valid.
Used for manipulating Paths. Paths will always exist either as a file or directory. Paths are '/' delimited when forming though may not be while retrieving. File names ".." will ascend a directory and '.' represents a no-op.
Definition: Path.hpp:9
Method FOpenMethod
The method used to open the file.
Definition: CYBFile.hpp:10
The File may or may not exist. It will be created if it doesn't. OpenMethod will be set to EXIST or C...
const API::Path & GetPath(void) const noexceptfinaloverride
Get the Path indicating the current File.
Definition: CYBFile.cpp:61
~File() finaloverride
Closes a file, saving changes.
Definition: CYBFile.cpp:48
unsigned long long CursorPosition(void) const noexceptfinaloverride
Get the current position of the read/write cursor in the Stream. Equivalent of Seek(0, SeekLocation::CURSOR)
Definition: CYBFile.cpp:57
unsigned long long Seek(const long long AOffset, const SeekLocation ALocation) const finaloverride
Set the cursor position in the Stream.
Precompiled header for inter-engine operations.
Any existing File will be overwritten and an empty file will be created.
Logger & FLogger
The Logger.
Definition: Context.hpp:12
Used for manipulating Paths. Paths will always exist either as a file or directory. Paths are '/' delimited when forming though may not be while retrieving. File names ".." will ascend a directory and '.' represents a no-op.
Definition: CYBPath.hpp:10
The File must exist.
Seek from the cursor position.
#define UNREACHABLE
Used for hardcore unreachable code paths when Assert::HCF is not enough. Should generally be avoided ...
Definition: Assert.hpp:27
Mode FOpenMode
The method used to open the file.
Definition: CYBFile.hpp:9
Debug messages, enabled/disabled by default in engine debug/release builds respectively.
void Capabilities(Mode &AMode, bool &ASeek) const noexceptfinaloverride
Get the capabilities of the stream.
Definition: CYBFile.cpp:52