summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/archive.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2014-11-17 22:26:54 -0500
committerGravatar bunnei2014-11-17 22:26:54 -0500
commitb66859714bda5968e36fed47a2ff8516bcfd2248 (patch)
treef1a933079afdfea73e76a187441733642489e2b0 /src/core/hle/kernel/archive.cpp
parentMerge pull request #201 from archshift/boss (diff)
parentArchive: Fixed to not destroy archive handle on close. (diff)
downloadyuzu-b66859714bda5968e36fed47a2ff8516bcfd2248.tar.gz
yuzu-b66859714bda5968e36fed47a2ff8516bcfd2248.tar.xz
yuzu-b66859714bda5968e36fed47a2ff8516bcfd2248.zip
Merge pull request #192 from bunnei/fs-fix-paths
FileSys: Updates backend code to use FileSys::Path and fixes binary path types.
Diffstat (limited to 'src/core/hle/kernel/archive.cpp')
-rw-r--r--src/core/hle/kernel/archive.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp
index 764082d71..8f1c95d0f 100644
--- a/src/core/hle/kernel/archive.cpp
+++ b/src/core/hle/kernel/archive.cpp
@@ -99,7 +99,6 @@ public:
99 case FileCommand::Close: 99 case FileCommand::Close:
100 { 100 {
101 DEBUG_LOG(KERNEL, "Close %s %s", GetTypeName().c_str(), GetName().c_str()); 101 DEBUG_LOG(KERNEL, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
102 Kernel::g_object_pool.Destroy<Archive>(GetHandle());
103 CloseArchive(backend->GetIdCode()); 102 CloseArchive(backend->GetIdCode());
104 break; 103 break;
105 } 104 }
@@ -129,12 +128,12 @@ public:
129class File : public Object { 128class File : public Object {
130public: 129public:
131 std::string GetTypeName() const override { return "File"; } 130 std::string GetTypeName() const override { return "File"; }
132 std::string GetName() const override { return path; } 131 std::string GetName() const override { return path.DebugStr(); }
133 132
134 static Kernel::HandleType GetStaticHandleType() { return HandleType::File; } 133 static Kernel::HandleType GetStaticHandleType() { return HandleType::File; }
135 Kernel::HandleType GetHandleType() const override { return HandleType::File; } 134 Kernel::HandleType GetHandleType() const override { return HandleType::File; }
136 135
137 std::string path; ///< Path of the file 136 FileSys::Path path; ///< Path of the file
138 std::unique_ptr<FileSys::File> backend; ///< File backend interface 137 std::unique_ptr<FileSys::File> backend; ///< File backend interface
139 138
140 /** 139 /**
@@ -221,12 +220,12 @@ public:
221class Directory : public Object { 220class Directory : public Object {
222public: 221public:
223 std::string GetTypeName() const override { return "Directory"; } 222 std::string GetTypeName() const override { return "Directory"; }
224 std::string GetName() const override { return path; } 223 std::string GetName() const override { return path.DebugStr(); }
225 224
226 static Kernel::HandleType GetStaticHandleType() { return HandleType::Directory; } 225 static Kernel::HandleType GetStaticHandleType() { return HandleType::Directory; }
227 Kernel::HandleType GetHandleType() const override { return HandleType::Directory; } 226 Kernel::HandleType GetHandleType() const override { return HandleType::Directory; }
228 227
229 std::string path; ///< Path of the directory 228 FileSys::Path path; ///< Path of the directory
230 std::unique_ptr<FileSys::Directory> backend; ///< File backend interface 229 std::unique_ptr<FileSys::Directory> backend; ///< File backend interface
231 230
232 /** 231 /**
@@ -304,8 +303,9 @@ Handle OpenArchive(FileSys::Archive::IdCode id_code) {
304 * @return Result of operation, 0 on success, otherwise error code 303 * @return Result of operation, 0 on success, otherwise error code
305 */ 304 */
306Result CloseArchive(FileSys::Archive::IdCode id_code) { 305Result CloseArchive(FileSys::Archive::IdCode id_code) {
307 if (1 != g_archive_map.erase(id_code)) { 306 auto itr = g_archive_map.find(id_code);
308 ERROR_LOG(KERNEL, "Cannot close archive %d", (int) id_code); 307 if (itr == g_archive_map.end()) {
308 ERROR_LOG(KERNEL, "Cannot close archive %d, does not exist!", (int)id_code);
309 return -1; 309 return -1;
310 } 310 }
311 311
@@ -366,7 +366,18 @@ Handle CreateArchive(FileSys::Archive* backend, const std::string& name) {
366 * @param mode Mode under which to open the File 366 * @param mode Mode under which to open the File
367 * @return Opened File object 367 * @return Opened File object
368 */ 368 */
369Handle OpenFileFromArchive(Handle archive_handle, const std::string& path, const FileSys::Mode mode) { 369Handle OpenFileFromArchive(Handle archive_handle, const FileSys::Path& path, const FileSys::Mode mode) {
370 // TODO(bunnei): Binary type files get a raw file pointer to the archive. Currently, we create
371 // the archive file handles at app loading, and then keep them persistent throughout execution.
372 // Archives file handles are just reused and not actually freed until emulation shut down.
373 // Verify if real hardware works this way, or if new handles are created each time
374 if (path.GetType() == FileSys::Binary)
375 // TODO(bunnei): FixMe - this is a hack to compensate for an incorrect FileSys backend
376 // design. While the functionally of this is OK, our implementation decision to separate
377 // normal files from archive file pointers is very likely wrong.
378 // See https://github.com/citra-emu/citra/issues/205
379 return archive_handle;
380
370 File* file = new File; 381 File* file = new File;
371 Handle handle = Kernel::g_object_pool.Create(file); 382 Handle handle = Kernel::g_object_pool.Create(file);
372 383
@@ -386,7 +397,7 @@ Handle OpenFileFromArchive(Handle archive_handle, const std::string& path, const
386 * @param path Path to the Directory inside of the Archive 397 * @param path Path to the Directory inside of the Archive
387 * @return Opened Directory object 398 * @return Opened Directory object
388 */ 399 */
389Result CreateDirectoryFromArchive(Handle archive_handle, const std::string& path) { 400Result CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) {
390 Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); 401 Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle);
391 if (archive == nullptr) 402 if (archive == nullptr)
392 return -1; 403 return -1;
@@ -401,7 +412,7 @@ Result CreateDirectoryFromArchive(Handle archive_handle, const std::string& path
401 * @param path Path to the Directory inside of the Archive 412 * @param path Path to the Directory inside of the Archive
402 * @return Opened Directory object 413 * @return Opened Directory object
403 */ 414 */
404Handle OpenDirectoryFromArchive(Handle archive_handle, const std::string& path) { 415Handle OpenDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) {
405 Directory* directory = new Directory; 416 Directory* directory = new Directory;
406 Handle handle = Kernel::g_object_pool.Create(directory); 417 Handle handle = Kernel::g_object_pool.Create(directory);
407 418