summaryrefslogtreecommitdiff
path: root/src/core/file_sys/filesystem.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/file_sys/filesystem.h')
-rw-r--r--src/core/file_sys/filesystem.h170
1 files changed, 0 insertions, 170 deletions
diff --git a/src/core/file_sys/filesystem.h b/src/core/file_sys/filesystem.h
deleted file mode 100644
index 1a32a373b..000000000
--- a/src/core/file_sys/filesystem.h
+++ /dev/null
@@ -1,170 +0,0 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <memory>
8#include <string>
9#include <utility>
10#include <vector>
11#include "common/bit_field.h"
12#include "common/common_types.h"
13#include "common/swap.h"
14#include "core/hle/result.h"
15
16namespace FileSys {
17
18class StorageBackend;
19class DirectoryBackend;
20
21// Path string type
22enum LowPathType : u32 {
23 Invalid = 0,
24 Empty = 1,
25 Binary = 2,
26 Char = 3,
27 Wchar = 4,
28};
29
30enum EntryType : u8 {
31 Directory = 0,
32 File = 1,
33};
34
35enum class Mode : u32 {
36 Read = 1,
37 Write = 2,
38 Append = 4,
39};
40
41class Path {
42public:
43 Path() : type(Invalid) {}
44 Path(const char* path) : type(Char), string(path) {}
45 Path(std::vector<u8> binary_data) : type(Binary), binary(std::move(binary_data)) {}
46 Path(LowPathType type, u32 size, u32 pointer);
47
48 LowPathType GetType() const {
49 return type;
50 }
51
52 /**
53 * Gets the string representation of the path for debugging
54 * @return String representation of the path for debugging
55 */
56 std::string DebugStr() const;
57
58 std::string AsString() const;
59 std::u16string AsU16Str() const;
60 std::vector<u8> AsBinary() const;
61
62private:
63 LowPathType type;
64 std::vector<u8> binary;
65 std::string string;
66 std::u16string u16str;
67};
68
69/// Parameters of the archive, as specified in the Create or Format call.
70struct ArchiveFormatInfo {
71 u32_le total_size; ///< The pre-defined size of the archive.
72 u32_le number_directories; ///< The pre-defined number of directories in the archive.
73 u32_le number_files; ///< The pre-defined number of files in the archive.
74 u8 duplicate_data; ///< Whether the archive should duplicate the data.
75};
76static_assert(std::is_pod<ArchiveFormatInfo>::value, "ArchiveFormatInfo is not POD");
77
78class FileSystemBackend : NonCopyable {
79public:
80 virtual ~FileSystemBackend() {}
81
82 /**
83 * Get a descriptive name for the archive (e.g. "RomFS", "SaveData", etc.)
84 */
85 virtual std::string GetName() const = 0;
86
87 /**
88 * Create a file specified by its path
89 * @param path Path relative to the Archive
90 * @param size The size of the new file, filled with zeroes
91 * @return Result of the operation
92 */
93 virtual ResultCode CreateFile(const std::string& path, u64 size) const = 0;
94
95 /**
96 * Delete a file specified by its path
97 * @param path Path relative to the archive
98 * @return Result of the operation
99 */
100 virtual ResultCode DeleteFile(const std::string& path) const = 0;
101
102 /**
103 * Create a directory specified by its path
104 * @param path Path relative to the archive
105 * @return Result of the operation
106 */
107 virtual ResultCode CreateDirectory(const std::string& path) const = 0;
108
109 /**
110 * Delete a directory specified by its path
111 * @param path Path relative to the archive
112 * @return Result of the operation
113 */
114 virtual ResultCode DeleteDirectory(const Path& path) const = 0;
115
116 /**
117 * Delete a directory specified by its path and anything under it
118 * @param path Path relative to the archive
119 * @return Result of the operation
120 */
121 virtual ResultCode DeleteDirectoryRecursively(const Path& path) const = 0;
122
123 /**
124 * Rename a File specified by its path
125 * @param src_path Source path relative to the archive
126 * @param dest_path Destination path relative to the archive
127 * @return Result of the operation
128 */
129 virtual ResultCode RenameFile(const std::string& src_path,
130 const std::string& dest_path) const = 0;
131
132 /**
133 * Rename a Directory specified by its path
134 * @param src_path Source path relative to the archive
135 * @param dest_path Destination path relative to the archive
136 * @return Result of the operation
137 */
138 virtual ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const = 0;
139
140 /**
141 * Open a file specified by its path, using the specified mode
142 * @param path Path relative to the archive
143 * @param mode Mode to open the file with
144 * @return Opened file, or error code
145 */
146 virtual ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
147 Mode mode) const = 0;
148
149 /**
150 * Open a directory specified by its path
151 * @param path Path relative to the archive
152 * @return Opened directory, or error code
153 */
154 virtual ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(
155 const std::string& path) const = 0;
156
157 /**
158 * Get the free space
159 * @return The number of free bytes in the archive
160 */
161 virtual u64 GetFreeSpaceSize() const = 0;
162
163 /**
164 * Get the type of the specified path
165 * @return The type of the specified path or error code
166 */
167 virtual ResultVal<EntryType> GetEntryType(const std::string& path) const = 0;
168};
169
170} // namespace FileSys