CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
LocalFileHandle.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2023 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Forward.hpp"
11
12#include "LocalFileIterator.hpp"
13
15
16#include <filesystem>
17
18namespace CeresEngine {
19
22 protected:
25
28
30 std::filesystem::path mFileSystemPath;
31
32 public:
35 ~LocalFileHandle() override;
36
37 public: // IFileHandle
39 [[nodiscard]] IFileSystem* getFileSystem() const override;
40
42 void updateFileInfo() override;
43
45 [[nodiscard]] StringView getPath() const override;
46
48 [[nodiscard]] bool exists() const override;
49
51 [[nodiscard]] bool isFile() const override;
52
54 [[nodiscard]] bool isDirectory() const override;
55
57 [[nodiscard]] bool isSymbolicLink() const override;
58
60 [[nodiscard]] FileIterator begin() const override;
61
63 [[nodiscard]] UInt64 getSize() const override;
64
66 [[nodiscard]] Int64 getAccessTime() const override;
67
69 [[nodiscard]] Int64 getModificationTime() const override;
70
72 [[nodiscard]] bool createDirectory() override;
73
75 [[nodiscard]] bool removeDirectory() override;
76
78 [[nodiscard]] bool copy(IFileHandle& dest) override;
79
81 [[nodiscard]] bool move(IFileHandle& dest) override;
82
84 [[nodiscard]] bool createLink(IFileHandle& dest) override;
85
88
90 [[nodiscard]] bool rename(StringView filename) override;
91
93 [[nodiscard]] bool remove() override;
94
96 [[nodiscard]] InputStream createInputStream(std::ios_base::openmode mode) const override;
97
99 [[nodiscard]] OutputStream createOutputStream(std::ios_base::openmode mode) override;
100 };
101
102} // namespace CeresEngine
A retain-release type of smart pointer.
Definition SmartPtr.hpp:132
An iterator that allows traversing over a file's children.
Definition FileHandle.hpp:432
Path to file or directory.
Definition FilePath.hpp:37
Base interface for file handles implementation.
Definition FileHandle.hpp:292
Interface for accessing file systems.
Definition FileSystem.hpp:28
A stream that provides read-only stream functionality.
Definition Stream.hpp:210
File handle for the local file system.
Definition LocalFileHandle.hpp:21
bool isDirectory() const override
Checks if item is a directory.
bool createSymbolicLink(IFileHandle &dest) override
Creates a symbolic link.
bool createLink(IFileHandle &dest) override
Creates a hard link.
bool createDirectory() override
Creates a new directory.
Int64 getModificationTime() const override
Gets time of last modification.
StringView getPath() const override
bool removeDirectory() override
Removes a directory.
bool isFile() const override
Checks if item is a file.
bool copy(IFileHandle &dest) override
Copies a file.
void updateFileInfo() override
Update file information.
OutputStream createOutputStream(std::ios_base::openmode mode) override
Creates an output stream to write to the file.
bool isSymbolicLink() const override
Checks if item is a symbolic link.
UInt64 getSize() const override
Gets the file size.
IFileSystem * getFileSystem() const override
Gets the backing IFileSystem for the handle.
bool remove() override
Removes a file.
LocalFileHandle(LocalFileSystem &fileSystem, StringView path)
Int64 getAccessTime() const override
Gets the time of last access.
FileIterator begin() const override
Gets an iterator that points to the first directory entry.
bool exists() const override
Checks if the file exists on the file system.
RC< LocalFileSystem > mFileSystem
The file system that created this handle.
Definition LocalFileHandle.hpp:24
FilePath mPath
Path to file or directory.
Definition LocalFileHandle.hpp:27
bool rename(StringView filename) override
Renames a file or directory.
InputStream createInputStream(std::ios_base::openmode mode) const override
Creates an input stream to read from the file.
std::filesystem::path mFileSystemPath
Same as mPath, but in the C++17 std::filesystem format.
Definition LocalFileHandle.hpp:30
LocalFileHandle(LocalFileSystem &fileSystem, String &&path)
bool move(IFileHandle &dest) override
Moves a file.
An implementation of a local file system.
Definition LocalFileSystem.hpp:17
A stream that provides write-only stream functionality.
Definition Stream.hpp:307
Definition Application.hpp:19
std::uint64_t UInt64
Definition DataTypes.hpp:26
std::int64_t Int64
Definition DataTypes.hpp:24
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25