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.h132
1 files changed, 0 insertions, 132 deletions
diff --git a/src/core/file_sys/filesystem.h b/src/core/file_sys/filesystem.h
index 295a3133e..2d925d9e4 100644
--- a/src/core/file_sys/filesystem.h
+++ b/src/core/file_sys/filesystem.h
@@ -66,136 +66,4 @@ private:
66 std::u16string u16str; 66 std::u16string u16str;
67}; 67};
68 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
170class FileSystemFactory : NonCopyable {
171public:
172 virtual ~FileSystemFactory() {}
173
174 /**
175 * Get a descriptive name for the archive (e.g. "RomFS", "SaveData", etc.)
176 */
177 virtual std::string GetName() const = 0;
178
179 /**
180 * Tries to open the archive of this type with the specified path
181 * @param path Path to the archive
182 * @return An ArchiveBackend corresponding operating specified archive path.
183 */
184 virtual ResultVal<std::unique_ptr<FileSystemBackend>> Open(const Path& path) = 0;
185
186 /**
187 * Deletes the archive contents and then re-creates the base folder
188 * @param path Path to the archive
189 * @return ResultCode of the operation, 0 on success
190 */
191 virtual ResultCode Format(const Path& path) = 0;
192
193 /**
194 * Retrieves the format info about the archive with the specified path
195 * @param path Path to the archive
196 * @return Format information about the archive or error code
197 */
198 virtual ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path) const = 0;
199};
200
201} // namespace FileSys 69} // namespace FileSys