2014-06-27 13:18:56 -07:00
|
|
|
// Copyright 2014 Citra Emulator Project
|
2014-12-16 21:38:14 -08:00
|
|
|
// Licensed under GPLv2 or any later version
|
2014-06-27 13:18:56 -07:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2014-12-15 00:41:02 -08:00
|
|
|
#include <memory>
|
|
|
|
|
2014-06-27 13:18:56 -07:00
|
|
|
#include "common/common_types.h"
|
2014-12-31 16:36:50 -08:00
|
|
|
#include "common/file_util.h"
|
2014-12-19 21:21:23 -08:00
|
|
|
#include "common/make_unique.h"
|
2014-06-27 13:18:56 -07:00
|
|
|
|
|
|
|
#include "core/file_sys/archive_romfs.h"
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// FileSys namespace
|
|
|
|
|
|
|
|
namespace FileSys {
|
|
|
|
|
2015-02-06 05:53:14 -08:00
|
|
|
ArchiveFactory_RomFS::ArchiveFactory_RomFS(const Loader::AppLoader& app_loader)
|
|
|
|
: romfs_data(std::make_shared<std::vector<u8>>()) {
|
2014-06-27 13:18:56 -07:00
|
|
|
// Load the RomFS from the app
|
2015-02-06 05:53:14 -08:00
|
|
|
if (Loader::ResultStatus::Success != app_loader.ReadRomFS(*romfs_data)) {
|
2014-12-05 17:53:49 -08:00
|
|
|
LOG_ERROR(Service_FS, "Unable to read RomFS!");
|
2014-06-27 13:18:56 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-06 05:53:14 -08:00
|
|
|
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-27 13:18:56 -07:00
|
|
|
} // namespace FileSys
|