2018-08-10 02:49:45 +02:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2018-09-24 03:50:16 +02:00
|
|
|
#include <fmt/format.h>
|
2018-08-10 02:49:45 +02:00
|
|
|
#include "core/file_sys/bis_factory.h"
|
2018-09-04 03:58:19 +02:00
|
|
|
#include "core/file_sys/registered_cache.h"
|
2018-08-10 02:49:45 +02:00
|
|
|
|
|
|
|
namespace FileSys {
|
|
|
|
|
2018-09-20 04:03:36 +02:00
|
|
|
BISFactory::BISFactory(VirtualDir nand_root_, VirtualDir load_root_)
|
|
|
|
: nand_root(std::move(nand_root_)), load_root(std::move(load_root_)),
|
2018-10-16 15:05:47 +02:00
|
|
|
sysnand_cache(std::make_unique<RegisteredCache>(
|
2018-08-16 23:05:30 +02:00
|
|
|
GetOrCreateDirectoryRelative(nand_root, "/system/Contents/registered"))),
|
2018-10-16 15:05:47 +02:00
|
|
|
usrnand_cache(std::make_unique<RegisteredCache>(
|
2018-08-16 23:05:30 +02:00
|
|
|
GetOrCreateDirectoryRelative(nand_root, "/user/Contents/registered"))) {}
|
2018-08-10 02:49:45 +02:00
|
|
|
|
2018-09-04 03:58:19 +02:00
|
|
|
BISFactory::~BISFactory() = default;
|
|
|
|
|
2018-10-16 15:05:47 +02:00
|
|
|
RegisteredCache* BISFactory::GetSystemNANDContents() const {
|
|
|
|
return sysnand_cache.get();
|
2018-08-10 02:49:45 +02:00
|
|
|
}
|
|
|
|
|
2018-10-16 15:05:47 +02:00
|
|
|
RegisteredCache* BISFactory::GetUserNANDContents() const {
|
|
|
|
return usrnand_cache.get();
|
2018-08-10 02:49:45 +02:00
|
|
|
}
|
|
|
|
|
2018-09-20 04:03:36 +02:00
|
|
|
VirtualDir BISFactory::GetModificationLoadRoot(u64 title_id) const {
|
|
|
|
// LayeredFS doesn't work on updates and title id-less homebrew
|
|
|
|
if (title_id == 0 || (title_id & 0x800) > 0)
|
|
|
|
return nullptr;
|
|
|
|
return GetOrCreateDirectoryRelative(load_root, fmt::format("/{:016X}", title_id));
|
|
|
|
}
|
|
|
|
|
2018-08-10 02:49:45 +02:00
|
|
|
} // namespace FileSys
|