Browse Source
file_sys: Cleanup to better match Switch file system constructs.
file_sys: Cleanup to better match Switch file system constructs.
file_sys: Add factory class for RomFS file system.nce_cpp
10 changed files with 136 additions and 63 deletions
-
14src/core/CMakeLists.txt
-
2src/core/file_sys/directory.h
-
4src/core/file_sys/filesystem.cpp
-
18src/core/file_sys/filesystem.h
-
2src/core/file_sys/path_parser.h
-
39src/core/file_sys/romfs_factory.cpp
-
35src/core/file_sys/romfs_factory.h
-
40src/core/file_sys/romfs_filesystem.cpp
-
18src/core/file_sys/romfs_filesystem.h
-
27src/core/file_sys/storage.h
@ -1,4 +1,4 @@ |
|||||
// Copyright 2014 Citra Emulator Project |
|
||||
|
// Copyright 2018 yuzu emulator team |
||||
// Licensed under GPLv2 or any later version |
// Licensed under GPLv2 or any later version |
||||
// Refer to the license.txt file included. |
// Refer to the license.txt file included. |
||||
|
|
||||
@ -0,0 +1,39 @@ |
|||||
|
// Copyright 2018 yuzu emulator team
|
||||
|
// Licensed under GPLv2 or any later version
|
||||
|
// Refer to the license.txt file included.
|
||||
|
|
||||
|
#include <algorithm>
|
||||
|
#include <memory>
|
||||
|
#include "common/common_types.h"
|
||||
|
#include "common/logging/log.h"
|
||||
|
#include "core/file_sys/romfs_factory.h"
|
||||
|
#include "core/file_sys/romfs_filesystem.h"
|
||||
|
|
||||
|
namespace FileSys { |
||||
|
|
||||
|
RomFS_Factory::RomFS_Factory(Loader::AppLoader& app_loader) { |
||||
|
// Load the RomFS from the app
|
||||
|
if (Loader::ResultStatus::Success != app_loader.ReadRomFS(romfs_file, data_offset, data_size)) { |
||||
|
LOG_ERROR(Service_FS, "Unable to read RomFS!"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
ResultVal<std::unique_ptr<FileSystemBackend>> RomFS_Factory::Open(const Path& path) { |
||||
|
auto archive = std::make_unique<RomFS_FileSystem>(romfs_file, data_offset, data_size); |
||||
|
return MakeResult<std::unique_ptr<FileSystemBackend>>(std::move(archive)); |
||||
|
} |
||||
|
|
||||
|
ResultCode RomFS_Factory::Format(const Path& path, |
||||
|
const FileSys::ArchiveFormatInfo& format_info) { |
||||
|
LOG_ERROR(Service_FS, "Unimplemented Format archive %s", GetName().c_str()); |
||||
|
// TODO(bunnei): Find the right error code for this
|
||||
|
return ResultCode(-1); |
||||
|
} |
||||
|
|
||||
|
ResultVal<ArchiveFormatInfo> RomFS_Factory::GetFormatInfo(const Path& path) const { |
||||
|
LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive %s", GetName().c_str()); |
||||
|
// TODO(bunnei): Find the right error code for this
|
||||
|
return ResultCode(-1); |
||||
|
} |
||||
|
|
||||
|
} // namespace FileSys
|
||||
@ -0,0 +1,35 @@ |
|||||
|
// Copyright 2018 yuzu emulator team |
||||
|
// Licensed under GPLv2 or any later version |
||||
|
// Refer to the license.txt file included. |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include <memory> |
||||
|
#include <string> |
||||
|
#include <vector> |
||||
|
#include "common/common_types.h" |
||||
|
#include "core/file_sys/filesystem.h" |
||||
|
#include "core/hle/result.h" |
||||
|
#include "core/loader/loader.h" |
||||
|
|
||||
|
namespace FileSys { |
||||
|
|
||||
|
/// File system interface to the RomFS archive |
||||
|
class RomFS_Factory final : public FileSystemFactory { |
||||
|
public: |
||||
|
explicit RomFS_Factory(Loader::AppLoader& app_loader); |
||||
|
|
||||
|
std::string GetName() const override { |
||||
|
return "ArchiveFactory_RomFS"; |
||||
|
} |
||||
|
ResultVal<std::unique_ptr<FileSystemBackend>> Open(const Path& path) override; |
||||
|
ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info) override; |
||||
|
ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path) const override; |
||||
|
|
||||
|
private: |
||||
|
std::shared_ptr<FileUtil::IOFile> romfs_file; |
||||
|
u64 data_offset; |
||||
|
u64 data_size; |
||||
|
}; |
||||
|
|
||||
|
} // namespace FileSys |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue