From a3107a6b571dedb8828b20ddcb709ec17db9715a Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 11 Nov 2014 19:27:35 -0500 Subject: FileSys: Updated backend code to use FileSys::Path instead of string for paths. --- src/core/hle/kernel/archive.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/core/hle/kernel/archive.cpp') diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp index 764082d71..5d734d042 100644 --- a/src/core/hle/kernel/archive.cpp +++ b/src/core/hle/kernel/archive.cpp @@ -129,12 +129,12 @@ public: class File : public Object { public: std::string GetTypeName() const override { return "File"; } - std::string GetName() const override { return path; } + std::string GetName() const override { return path.DebugStr(); } static Kernel::HandleType GetStaticHandleType() { return HandleType::File; } Kernel::HandleType GetHandleType() const override { return HandleType::File; } - std::string path; ///< Path of the file + FileSys::Path path; ///< Path of the file std::unique_ptr backend; ///< File backend interface /** @@ -221,12 +221,12 @@ public: class Directory : public Object { public: std::string GetTypeName() const override { return "Directory"; } - std::string GetName() const override { return path; } + std::string GetName() const override { return path.DebugStr(); } static Kernel::HandleType GetStaticHandleType() { return HandleType::Directory; } Kernel::HandleType GetHandleType() const override { return HandleType::Directory; } - std::string path; ///< Path of the directory + FileSys::Path path; ///< Path of the directory std::unique_ptr backend; ///< File backend interface /** @@ -366,7 +366,7 @@ Handle CreateArchive(FileSys::Archive* backend, const std::string& name) { * @param mode Mode under which to open the File * @return Opened File object */ -Handle OpenFileFromArchive(Handle archive_handle, const std::string& path, const FileSys::Mode mode) { +Handle OpenFileFromArchive(Handle archive_handle, const FileSys::Path& path, const FileSys::Mode mode) { File* file = new File; Handle handle = Kernel::g_object_pool.Create(file); @@ -386,7 +386,7 @@ Handle OpenFileFromArchive(Handle archive_handle, const std::string& path, const * @param path Path to the Directory inside of the Archive * @return Opened Directory object */ -Result CreateDirectoryFromArchive(Handle archive_handle, const std::string& path) { +Result CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) { Archive* archive = Kernel::g_object_pool.GetFast(archive_handle); if (archive == nullptr) return -1; @@ -401,7 +401,7 @@ Result CreateDirectoryFromArchive(Handle archive_handle, const std::string& path * @param path Path to the Directory inside of the Archive * @return Opened Directory object */ -Handle OpenDirectoryFromArchive(Handle archive_handle, const std::string& path) { +Handle OpenDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) { Directory* directory = new Directory; Handle handle = Kernel::g_object_pool.Create(directory); -- cgit v1.2.3 From 3e09c07378a73b959c02830e1c0ffb584a60087c Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 14 Nov 2014 00:07:02 -0500 Subject: FS_User: Support FileSye::Path in a more generic way. added a todo to kernel archive --- src/core/hle/kernel/archive.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/core/hle/kernel/archive.cpp') diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp index 5d734d042..e911f4dc9 100644 --- a/src/core/hle/kernel/archive.cpp +++ b/src/core/hle/kernel/archive.cpp @@ -367,6 +367,17 @@ Handle CreateArchive(FileSys::Archive* backend, const std::string& name) { * @return Opened File object */ Handle OpenFileFromArchive(Handle archive_handle, const FileSys::Path& path, const FileSys::Mode mode) { + // TODO(bunnei): Binary type files get a raw file pointer to the archive. Currently, we create + // the archive file handles at app loading, and then keep them persistent throughout execution. + // Archives file handles are just reused and not actually freed until emulation shut down. + // Verify if real hardware works this way, or if new handles are created each time + if (path.GetType() == FileSys::Binary) + // TODO(bunnei): FixMe - this is a hack to compensate for an incorrect FileSys backend + // design. While the functionally of this is OK, our implementation decision to separate + // normal files from archive file pointers is very likely wrong. + // See https://github.com/citra-emu/citra/issues/205 + return archive_handle; + File* file = new File; Handle handle = Kernel::g_object_pool.Create(file); -- cgit v1.2.3 From bcb0dbf7e168f383e8be2971fc0362668ca08afe Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 14 Nov 2014 23:47:32 -0500 Subject: Archive: Fixed close archive before freeing. --- src/core/hle/kernel/archive.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/kernel/archive.cpp') diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp index e911f4dc9..ece4cd73f 100644 --- a/src/core/hle/kernel/archive.cpp +++ b/src/core/hle/kernel/archive.cpp @@ -99,8 +99,8 @@ public: case FileCommand::Close: { DEBUG_LOG(KERNEL, "Close %s %s", GetTypeName().c_str(), GetName().c_str()); - Kernel::g_object_pool.Destroy(GetHandle()); CloseArchive(backend->GetIdCode()); + Kernel::g_object_pool.Destroy(GetHandle()); break; } // Unknown command... -- cgit v1.2.3 From 11641b5e7913a90d2428d7a3ad04b9963e9fa278 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 15 Nov 2014 01:08:00 -0500 Subject: Archive: Fixed to not destroy archive handle on close. --- src/core/hle/kernel/archive.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core/hle/kernel/archive.cpp') diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp index ece4cd73f..8f1c95d0f 100644 --- a/src/core/hle/kernel/archive.cpp +++ b/src/core/hle/kernel/archive.cpp @@ -100,7 +100,6 @@ public: { DEBUG_LOG(KERNEL, "Close %s %s", GetTypeName().c_str(), GetName().c_str()); CloseArchive(backend->GetIdCode()); - Kernel::g_object_pool.Destroy(GetHandle()); break; } // Unknown command... @@ -304,8 +303,9 @@ Handle OpenArchive(FileSys::Archive::IdCode id_code) { * @return Result of operation, 0 on success, otherwise error code */ Result CloseArchive(FileSys::Archive::IdCode id_code) { - if (1 != g_archive_map.erase(id_code)) { - ERROR_LOG(KERNEL, "Cannot close archive %d", (int) id_code); + auto itr = g_archive_map.find(id_code); + if (itr == g_archive_map.end()) { + ERROR_LOG(KERNEL, "Cannot close archive %d, does not exist!", (int)id_code); return -1; } -- cgit v1.2.3