2014-06-28 01:48:56 +05:30
|
|
|
// Copyright 2014 Citra Emulator Project
|
2014-12-17 11:08:14 +05:30
|
|
|
// Licensed under GPLv2 or any later version
|
2014-06-28 01:48:56 +05:30
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2014-12-15 14:11:02 +05:30
|
|
|
#include <memory>
|
|
|
|
|
2014-06-28 01:48:56 +05:30
|
|
|
#include "common/common_types.h"
|
2015-01-01 06:06:50 +05:30
|
|
|
#include "common/file_util.h"
|
2015-05-06 12:36:12 +05:30
|
|
|
#include "common/logging/log.h"
|
2014-12-20 10:51:23 +05:30
|
|
|
#include "common/make_unique.h"
|
2014-06-28 01:48:56 +05:30
|
|
|
|
|
|
|
#include "core/file_sys/archive_romfs.h"
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// FileSys namespace
|
|
|
|
|
|
|
|
namespace FileSys {
|
|
|
|
|
2015-02-06 19:23:14 +05:30
|
|
|
ArchiveFactory_RomFS::ArchiveFactory_RomFS(const Loader::AppLoader& app_loader)
|
|
|
|
: romfs_data(std::make_shared<std::vector<u8>>()) {
|
2014-06-28 01:48:56 +05:30
|
|
|
// Load the RomFS from the app
|
2015-02-06 19:23:14 +05:30
|
|
|
if (Loader::ResultStatus::Success != app_loader.ReadRomFS(*romfs_data)) {
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_ERROR(Service_FS, "Unable to read RomFS!");
|
2014-06-28 01:48:56 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-06 19:23:14 +05:30
|
|
|
ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_RomFS::Open(const Path& path) {
|
|
|
|
auto archive = Common::make_unique<IVFCArchive>(romfs_data);
|
|
|
|
return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
|
|
|
|
}
|
|
|
|
|
|
|
|
ResultCode ArchiveFactory_RomFS::Format(const Path& path) {
|
|
|
|
LOG_ERROR(Service_FS, "Attempted to format a RomFS archive.");
|
|
|
|
// TODO: Verify error code
|
|
|
|
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS,
|
|
|
|
ErrorSummary::NotSupported, ErrorLevel::Permanent);
|
|
|
|
}
|
|
|
|
|
2014-06-28 01:48:56 +05:30
|
|
|
} // namespace FileSys
|