diff options
| author | 2015-01-30 12:32:46 -0200 | |
|---|---|---|
| committer | 2015-02-02 15:36:58 -0200 | |
| commit | 5e91fc0d1aa806a9635e06e047d5367988f21093 (patch) | |
| tree | 1e96f03d7fe20f8f6d44f8cee879092846c4e8a0 /src | |
| parent | Merge pull request #517 from bunnei/blend-factors (diff) | |
| download | yuzu-5e91fc0d1aa806a9635e06e047d5367988f21093.tar.gz yuzu-5e91fc0d1aa806a9635e06e047d5367988f21093.tar.xz yuzu-5e91fc0d1aa806a9635e06e047d5367988f21093.zip | |
Filesys: Move creation of Handles for File/Directory to service handlers
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/fs/archive.cpp | 24 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.h | 14 | ||||
| -rw-r--r-- | src/core/hle/service/fs/fs_user.cpp | 27 |
3 files changed, 33 insertions, 32 deletions
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 43eef034e..0ce9ad4d6 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp | |||
| @@ -303,7 +303,8 @@ ResultCode CreateArchive(std::unique_ptr<FileSys::ArchiveBackend>&& backend, Arc | |||
| 303 | return RESULT_SUCCESS; | 303 | return RESULT_SUCCESS; |
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | ResultVal<Handle> OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path, const FileSys::Mode mode) { | 306 | ResultVal<Kernel::SharedPtr<Kernel::Session>> OpenFileFromArchive(ArchiveHandle archive_handle, |
| 307 | const FileSys::Path& path, const FileSys::Mode mode) { | ||
| 307 | Archive* archive = GetArchive(archive_handle); | 308 | Archive* archive = GetArchive(archive_handle); |
| 308 | if (archive == nullptr) | 309 | if (archive == nullptr) |
| 309 | return ERR_INVALID_HANDLE; | 310 | return ERR_INVALID_HANDLE; |
| @@ -314,10 +315,8 @@ ResultVal<Handle> OpenFileFromArchive(ArchiveHandle archive_handle, const FileSy | |||
| 314 | ErrorSummary::NotFound, ErrorLevel::Status); | 315 | ErrorSummary::NotFound, ErrorLevel::Status); |
| 315 | } | 316 | } |
| 316 | 317 | ||
| 317 | auto file = Common::make_unique<File>(std::move(backend), path); | 318 | auto file = Kernel::SharedPtr<File>(new File(std::move(backend), path)); |
| 318 | // TOOD(yuriks): Fix error reporting | 319 | return MakeResult<Kernel::SharedPtr<Kernel::Session>>(std::move(file)); |
| 319 | Handle handle = Kernel::g_handle_table.Create(file.release()).ValueOr(INVALID_HANDLE); | ||
| 320 | return MakeResult<Handle>(handle); | ||
| 321 | } | 320 | } |
| 322 | 321 | ||
| 323 | ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { | 322 | ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { |
| @@ -403,13 +402,8 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons | |||
| 403 | ErrorSummary::NothingHappened, ErrorLevel::Status); | 402 | ErrorSummary::NothingHappened, ErrorLevel::Status); |
| 404 | } | 403 | } |
| 405 | 404 | ||
| 406 | /** | 405 | ResultVal<Kernel::SharedPtr<Kernel::Session>> OpenDirectoryFromArchive(ArchiveHandle archive_handle, |
| 407 | * Open a Directory from an Archive | 406 | const FileSys::Path& path) { |
| 408 | * @param archive_handle Handle to an open Archive object | ||
| 409 | * @param path Path to the Directory inside of the Archive | ||
| 410 | * @return Opened Directory object | ||
| 411 | */ | ||
| 412 | ResultVal<Handle> OpenDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { | ||
| 413 | Archive* archive = GetArchive(archive_handle); | 407 | Archive* archive = GetArchive(archive_handle); |
| 414 | if (archive == nullptr) | 408 | if (archive == nullptr) |
| 415 | return ERR_INVALID_HANDLE; | 409 | return ERR_INVALID_HANDLE; |
| @@ -420,10 +414,8 @@ ResultVal<Handle> OpenDirectoryFromArchive(ArchiveHandle archive_handle, const F | |||
| 420 | ErrorSummary::NotFound, ErrorLevel::Permanent); | 414 | ErrorSummary::NotFound, ErrorLevel::Permanent); |
| 421 | } | 415 | } |
| 422 | 416 | ||
| 423 | auto directory = Common::make_unique<Directory>(std::move(backend), path); | 417 | auto directory = Kernel::SharedPtr<Directory>(new Directory(std::move(backend), path)); |
| 424 | // TOOD(yuriks): Fix error reporting | 418 | return MakeResult<Kernel::SharedPtr<Kernel::Session>>(std::move(directory)); |
| 425 | Handle handle = Kernel::g_handle_table.Create(directory.release()).ValueOr(INVALID_HANDLE); | ||
| 426 | return MakeResult<Handle>(handle); | ||
| 427 | } | 419 | } |
| 428 | 420 | ||
| 429 | ResultCode FormatSaveData() { | 421 | ResultCode FormatSaveData() { |
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index ba674d7f6..ab5ea4da8 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h | |||
| @@ -15,6 +15,10 @@ extern const std::string SYSTEM_ID; | |||
| 15 | /// The scrambled SD card CID, also known as ID1 | 15 | /// The scrambled SD card CID, also known as ID1 |
| 16 | extern const std::string SDCARD_ID; | 16 | extern const std::string SDCARD_ID; |
| 17 | 17 | ||
| 18 | namespace Kernel { | ||
| 19 | class Session; | ||
| 20 | } | ||
| 21 | |||
| 18 | namespace Service { | 22 | namespace Service { |
| 19 | namespace FS { | 23 | namespace FS { |
| 20 | 24 | ||
| @@ -58,9 +62,10 @@ ResultCode CreateArchive(std::unique_ptr<FileSys::ArchiveBackend>&& backend, Arc | |||
| 58 | * @param archive_handle Handle to an open Archive object | 62 | * @param archive_handle Handle to an open Archive object |
| 59 | * @param path Path to the File inside of the Archive | 63 | * @param path Path to the File inside of the Archive |
| 60 | * @param mode Mode under which to open the File | 64 | * @param mode Mode under which to open the File |
| 61 | * @return Handle to the opened File object | 65 | * @return The opened File object as a Session |
| 62 | */ | 66 | */ |
| 63 | ResultVal<Handle> OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path, const FileSys::Mode mode); | 67 | ResultVal<Kernel::SharedPtr<Kernel::Session>> OpenFileFromArchive(ArchiveHandle archive_handle, |
| 68 | const FileSys::Path& path, const FileSys::Mode mode); | ||
| 64 | 69 | ||
| 65 | /** | 70 | /** |
| 66 | * Delete a File from an Archive | 71 | * Delete a File from an Archive |
| @@ -121,9 +126,10 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons | |||
| 121 | * Open a Directory from an Archive | 126 | * Open a Directory from an Archive |
| 122 | * @param archive_handle Handle to an open Archive object | 127 | * @param archive_handle Handle to an open Archive object |
| 123 | * @param path Path to the Directory inside of the Archive | 128 | * @param path Path to the Directory inside of the Archive |
| 124 | * @return Handle to the opened File object | 129 | * @return The opened Directory object as a Session |
| 125 | */ | 130 | */ |
| 126 | ResultVal<Handle> OpenDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path); | 131 | ResultVal<Kernel::SharedPtr<Kernel::Session>> OpenDirectoryFromArchive(ArchiveHandle archive_handle, |
| 132 | const FileSys::Path& path); | ||
| 127 | 133 | ||
| 128 | /** | 134 | /** |
| 129 | * Creates a blank SaveData archive. | 135 | * Creates a blank SaveData archive. |
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index c495b6f3c..9cb7d809a 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp | |||
| @@ -14,6 +14,9 @@ | |||
| 14 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 14 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 15 | // Namespace FS_User | 15 | // Namespace FS_User |
| 16 | 16 | ||
| 17 | using Kernel::SharedPtr; | ||
| 18 | using Kernel::Session; | ||
| 19 | |||
| 17 | namespace Service { | 20 | namespace Service { |
| 18 | namespace FS { | 21 | namespace FS { |
| 19 | 22 | ||
| @@ -58,10 +61,10 @@ static void OpenFile(Service::Interface* self) { | |||
| 58 | 61 | ||
| 59 | LOG_DEBUG(Service_FS, "path=%s, mode=%d attrs=%u", file_path.DebugStr().c_str(), mode.hex, attributes); | 62 | LOG_DEBUG(Service_FS, "path=%s, mode=%d attrs=%u", file_path.DebugStr().c_str(), mode.hex, attributes); |
| 60 | 63 | ||
| 61 | ResultVal<Handle> handle = OpenFileFromArchive(archive_handle, file_path, mode); | 64 | ResultVal<SharedPtr<Session>> file_res = OpenFileFromArchive(archive_handle, file_path, mode); |
| 62 | cmd_buff[1] = handle.Code().raw; | 65 | cmd_buff[1] = file_res.Code().raw; |
| 63 | if (handle.Succeeded()) { | 66 | if (file_res.Succeeded()) { |
| 64 | cmd_buff[3] = *handle; | 67 | cmd_buff[3] = Kernel::g_handle_table.Create(*file_res).MoveFrom(); |
| 65 | } else { | 68 | } else { |
| 66 | cmd_buff[3] = 0; | 69 | cmd_buff[3] = 0; |
| 67 | LOG_ERROR(Service_FS, "failed to get a handle for file %s", file_path.DebugStr().c_str()); | 70 | LOG_ERROR(Service_FS, "failed to get a handle for file %s", file_path.DebugStr().c_str()); |
| @@ -114,10 +117,10 @@ static void OpenFileDirectly(Service::Interface* self) { | |||
| 114 | } | 117 | } |
| 115 | SCOPE_EXIT({ CloseArchive(*archive_handle); }); | 118 | SCOPE_EXIT({ CloseArchive(*archive_handle); }); |
| 116 | 119 | ||
| 117 | ResultVal<Handle> handle = OpenFileFromArchive(*archive_handle, file_path, mode); | 120 | ResultVal<SharedPtr<Session>> file_res = OpenFileFromArchive(*archive_handle, file_path, mode); |
| 118 | cmd_buff[1] = handle.Code().raw; | 121 | cmd_buff[1] = file_res.Code().raw; |
| 119 | if (handle.Succeeded()) { | 122 | if (file_res.Succeeded()) { |
| 120 | cmd_buff[3] = *handle; | 123 | cmd_buff[3] = Kernel::g_handle_table.Create(*file_res).MoveFrom(); |
| 121 | } else { | 124 | } else { |
| 122 | cmd_buff[3] = 0; | 125 | cmd_buff[3] = 0; |
| 123 | LOG_ERROR(Service_FS, "failed to get a handle for file %s", file_path.DebugStr().c_str()); | 126 | LOG_ERROR(Service_FS, "failed to get a handle for file %s", file_path.DebugStr().c_str()); |
| @@ -334,10 +337,10 @@ static void OpenDirectory(Service::Interface* self) { | |||
| 334 | 337 | ||
| 335 | LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str()); | 338 | LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str()); |
| 336 | 339 | ||
| 337 | ResultVal<Handle> handle = OpenDirectoryFromArchive(archive_handle, dir_path); | 340 | ResultVal<SharedPtr<Session>> dir_res = OpenDirectoryFromArchive(archive_handle, dir_path); |
| 338 | cmd_buff[1] = handle.Code().raw; | 341 | cmd_buff[1] = dir_res.Code().raw; |
| 339 | if (handle.Succeeded()) { | 342 | if (dir_res.Succeeded()) { |
| 340 | cmd_buff[3] = *handle; | 343 | cmd_buff[3] = Kernel::g_handle_table.Create(*dir_res).MoveFrom(); |
| 341 | } else { | 344 | } else { |
| 342 | LOG_ERROR(Service_FS, "failed to get a handle for directory"); | 345 | LOG_ERROR(Service_FS, "failed to get a handle for directory"); |
| 343 | } | 346 | } |