summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2014-11-18 04:26:54 +0100
committerbunnei <bunneidev@gmail.com>2014-11-18 04:26:54 +0100
commitb66859714bda5968e36fed47a2ff8516bcfd2248 (patch)
treef1a933079afdfea73e76a187441733642489e2b0 /src/core/hle/kernel
parentMerge pull request #201 from archshift/boss (diff)
parentArchive: Fixed to not destroy archive handle on close. (diff)
downloadyuzu-b66859714bda5968e36fed47a2ff8516bcfd2248.tar
yuzu-b66859714bda5968e36fed47a2ff8516bcfd2248.tar.gz
yuzu-b66859714bda5968e36fed47a2ff8516bcfd2248.tar.bz2
yuzu-b66859714bda5968e36fed47a2ff8516bcfd2248.tar.lz
yuzu-b66859714bda5968e36fed47a2ff8516bcfd2248.tar.xz
yuzu-b66859714bda5968e36fed47a2ff8516bcfd2248.tar.zst
yuzu-b66859714bda5968e36fed47a2ff8516bcfd2248.zip
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/archive.cpp31
-rw-r--r--src/core/hle/kernel/archive.h6
2 files changed, 24 insertions, 13 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:
case FileCommand::Close:
{
DEBUG_LOG(KERNEL, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
- Kernel::g_object_pool.Destroy<Archive>(GetHandle());
CloseArchive(backend->GetIdCode());
break;
}
@@ -129,12 +128,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<FileSys::File> backend; ///< File backend interface
/**
@@ -221,12 +220,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<FileSys::Directory> backend; ///< File backend interface
/**
@@ -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;
}
@@ -366,7 +366,18 @@ 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) {
+ // 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);
@@ -386,7 +397,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>(archive_handle);
if (archive == nullptr)
return -1;
@@ -401,7 +412,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);
diff --git a/src/core/hle/kernel/archive.h b/src/core/hle/kernel/archive.h
index 0230996b6..9c6015506 100644
--- a/src/core/hle/kernel/archive.h
+++ b/src/core/hle/kernel/archive.h
@@ -43,7 +43,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& name, const FileSys::Mode mode);
+Handle OpenFileFromArchive(Handle archive_handle, const FileSys::Path& path, const FileSys::Mode mode);
/**
* Create a Directory from an Archive
@@ -51,7 +51,7 @@ Handle OpenFileFromArchive(Handle archive_handle, const std::string& name, const
* @param path Path to the Directory inside of the Archive
* @return Whether creation of directory succeeded
*/
-Result CreateDirectoryFromArchive(Handle archive_handle, const std::string& name);
+Result CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path);
/**
* Open a Directory from an Archive
@@ -59,7 +59,7 @@ Result CreateDirectoryFromArchive(Handle archive_handle, const std::string& name
* @param path Path to the Directory inside of the Archive
* @return Opened Directory object
*/
-Handle OpenDirectoryFromArchive(Handle archive_handle, const std::string& name);
+Handle OpenDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path);
/// Initialize archives
void ArchiveInit();