Rename v_file and v_dir
This commit is contained in:
@@ -57,7 +57,7 @@ struct RomFSSuperblock {
|
||||
};
|
||||
static_assert(sizeof(RomFSSuperblock) == 0xE8, "RomFSSuperblock has incorrect size.");
|
||||
|
||||
NCA::NCA(v_file file_) : file(file_) {
|
||||
NCA::NCA(VirtualFile file_) : file(file_) {
|
||||
if (sizeof(NCAHeader) != file->ReadObject(&header))
|
||||
NGLOG_CRITICAL(Loader, "File reader errored out during header read.");
|
||||
|
||||
@@ -149,15 +149,15 @@ u64 NCA::GetTitleId() const {
|
||||
return header.title_id;
|
||||
}
|
||||
|
||||
v_file NCA::GetRomFS() const {
|
||||
VirtualFile NCA::GetRomFS() const {
|
||||
return romfs;
|
||||
}
|
||||
|
||||
v_dir NCA::GetExeFS() const {
|
||||
VirtualDir NCA::GetExeFS() const {
|
||||
return exefs;
|
||||
}
|
||||
|
||||
bool NCA::ReplaceFileWithSubdirectory(v_file file, v_dir dir) {
|
||||
bool NCA::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) {
|
||||
return false;
|
||||
}
|
||||
} // namespace FileSys
|
||||
|
||||
@@ -55,19 +55,19 @@ static bool IsValidNCA(const NCAHeader& header) {
|
||||
// An implementation of VfsDirectory that represents a Nintendo Content Archive (NCA) conatiner.
|
||||
// After construction, use GetStatus to determine if the file is valid and ready to be used.
|
||||
class NCA : public ReadOnlyVfsDirectory {
|
||||
std::vector<v_dir> dirs{};
|
||||
std::vector<v_file> files{};
|
||||
std::vector<VirtualDir> dirs{};
|
||||
std::vector<VirtualFile> files{};
|
||||
|
||||
v_file romfs = nullptr;
|
||||
v_dir exefs = nullptr;
|
||||
v_file file;
|
||||
VirtualFile romfs = nullptr;
|
||||
VirtualDir exefs = nullptr;
|
||||
VirtualFile file;
|
||||
|
||||
NCAHeader header{};
|
||||
|
||||
Loader::ResultStatus status{};
|
||||
|
||||
public:
|
||||
explicit NCA(v_file file);
|
||||
explicit NCA(VirtualFile file);
|
||||
Loader::ResultStatus GetStatus() const;
|
||||
|
||||
std::vector<std::shared_ptr<VfsFile>> GetFiles() const override;
|
||||
@@ -78,11 +78,11 @@ public:
|
||||
NCAContentType GetType() const;
|
||||
u64 GetTitleId() const;
|
||||
|
||||
v_file GetRomFS() const;
|
||||
v_dir GetExeFS() const;
|
||||
VirtualFile GetRomFS() const;
|
||||
VirtualDir GetExeFS() const;
|
||||
|
||||
protected:
|
||||
bool ReplaceFileWithSubdirectory(v_file file, v_dir dir) override;
|
||||
bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override;
|
||||
};
|
||||
|
||||
} // namespace FileSys
|
||||
|
||||
@@ -109,7 +109,7 @@ void PartitionFilesystem::PrintDebugInfo() const {
|
||||
}
|
||||
}
|
||||
|
||||
bool PartitionFilesystem::ReplaceFileWithSubdirectory(v_file file, v_dir dir) {
|
||||
bool PartitionFilesystem::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) {
|
||||
auto iter = std::find(pfs_files.begin(), pfs_files.end(), file);
|
||||
if (iter == pfs_files.end())
|
||||
return false;
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
void PrintDebugInfo() const;
|
||||
|
||||
protected:
|
||||
bool ReplaceFileWithSubdirectory(v_file file, v_dir dir) override;
|
||||
bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override;
|
||||
|
||||
private:
|
||||
struct Header {
|
||||
@@ -79,8 +79,8 @@ private:
|
||||
bool is_hfs;
|
||||
size_t content_offset;
|
||||
|
||||
std::vector<v_file> pfs_files;
|
||||
std::vector<v_dir> pfs_dirs;
|
||||
std::vector<VirtualFile> pfs_files;
|
||||
std::vector<VirtualDir> pfs_dirs;
|
||||
};
|
||||
|
||||
} // namespace FileSys
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
Loader::ResultStatus ProgramMetadata::Load(v_file file) {
|
||||
Loader::ResultStatus ProgramMetadata::Load(VirtualFile file) {
|
||||
size_t total_size = static_cast<size_t>(file->GetSize());
|
||||
if (total_size < sizeof(Header))
|
||||
return Loader::ResultStatus::Error;
|
||||
|
||||
@@ -38,7 +38,7 @@ enum class ProgramFilePermission : u64 {
|
||||
*/
|
||||
class ProgramMetadata {
|
||||
public:
|
||||
Loader::ResultStatus Load(v_file file);
|
||||
Loader::ResultStatus Load(VirtualFile file);
|
||||
|
||||
bool Is64BitProgram() const;
|
||||
ProgramAddressSpaceType GetAddressSpaceType() const;
|
||||
|
||||
@@ -18,8 +18,8 @@ struct VfsDirectory;
|
||||
} // namespace FileSys
|
||||
|
||||
// Convenience typedefs to use VfsDirectory and VfsFile
|
||||
using v_dir = std::shared_ptr<FileSys::VfsDirectory>;
|
||||
using v_file = std::shared_ptr<FileSys::VfsFile>;
|
||||
using VirtualDir = std::shared_ptr<FileSys::VfsDirectory>;
|
||||
using VirtualFile = std::shared_ptr<FileSys::VfsFile>;
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
@@ -206,7 +206,7 @@ struct VfsDirectory : NonCopyable {
|
||||
protected:
|
||||
// Backend for InterpretAsDirectory.
|
||||
// Removes all references to file and adds a reference to dir in the directory's implementation.
|
||||
virtual bool ReplaceFileWithSubdirectory(v_file file, v_dir dir) = 0;
|
||||
virtual bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) = 0;
|
||||
};
|
||||
|
||||
// A convenience partial-implementation of VfsDirectory that stubs out methods that should only work
|
||||
|
||||
@@ -153,7 +153,7 @@ bool RealVfsDirectory::Rename(const std::string& name) {
|
||||
return FileUtil::Rename(path, parent_path + DIR_SEP + name);
|
||||
}
|
||||
|
||||
bool RealVfsDirectory::ReplaceFileWithSubdirectory(v_file file, v_dir dir) {
|
||||
bool RealVfsDirectory::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) {
|
||||
auto iter = std::find(files.begin(), files.end(), file);
|
||||
if (iter == files.end())
|
||||
return false;
|
||||
|
||||
@@ -50,7 +50,7 @@ struct RealVfsDirectory : public VfsDirectory {
|
||||
bool Rename(const std::string& name) override;
|
||||
|
||||
protected:
|
||||
bool ReplaceFileWithSubdirectory(v_file file, v_dir dir) override;
|
||||
bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override;
|
||||
|
||||
private:
|
||||
std::string path;
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
namespace Service::FileSystem {
|
||||
|
||||
static v_dir GetDirectoryRelativeWrapped(v_dir base, const std::string& dir_name) {
|
||||
static VirtualDir GetDirectoryRelativeWrapped(VirtualDir base, const std::string& dir_name) {
|
||||
if (dir_name == "." || dir_name == "" || dir_name == "/" || dir_name == "\\")
|
||||
return base;
|
||||
|
||||
return base->GetDirectoryRelative(dir_name);
|
||||
}
|
||||
|
||||
VfsDirectoryServiceWrapper::VfsDirectoryServiceWrapper(v_dir backing_) : backing(backing_) {}
|
||||
VfsDirectoryServiceWrapper::VfsDirectoryServiceWrapper(VirtualDir backing_) : backing(backing_) {}
|
||||
|
||||
std::string VfsDirectoryServiceWrapper::GetName() const {
|
||||
return backing->GetName();
|
||||
@@ -122,16 +122,16 @@ ResultCode VfsDirectoryServiceWrapper::RenameDirectory(const std::string& src_pa
|
||||
return ResultCode(-1);
|
||||
}
|
||||
|
||||
ResultVal<v_file> VfsDirectoryServiceWrapper::OpenFile(const std::string& path,
|
||||
ResultVal<VirtualFile> VfsDirectoryServiceWrapper::OpenFile(const std::string& path,
|
||||
FileSys::Mode mode) const {
|
||||
auto file = backing->GetFileRelative(path);
|
||||
if (file == nullptr)
|
||||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
// TODO(DarkLordZach): Error checking/result modification with different modes.
|
||||
return MakeResult<v_file>(file);
|
||||
return MakeResult<VirtualFile>(file);
|
||||
}
|
||||
|
||||
ResultVal<v_dir> VfsDirectoryServiceWrapper::OpenDirectory(const std::string& path) {
|
||||
ResultVal<VirtualDir> VfsDirectoryServiceWrapper::OpenDirectory(const std::string& path) {
|
||||
auto dir = GetDirectoryRelativeWrapped(backing, path);
|
||||
if (dir == nullptr)
|
||||
return ResultCode(-1);
|
||||
@@ -164,7 +164,7 @@ ResultVal<FileSys::EntryType> VfsDirectoryServiceWrapper::GetEntryType(
|
||||
// registration time.
|
||||
struct SaveDataDeferredFilesystem : DeferredFilesystem {
|
||||
protected:
|
||||
v_dir CreateFilesystem() override {
|
||||
VirtualDir CreateFilesystem() override {
|
||||
u64 title_id = Core::CurrentProcess()->program_id;
|
||||
// TODO(DarkLordZach): Users
|
||||
u32 user_id = 0;
|
||||
@@ -182,7 +182,7 @@ protected:
|
||||
* is never removed until UnregisterFileSystems is called.
|
||||
*/
|
||||
static boost::container::flat_map<Type, std::unique_ptr<DeferredFilesystem>> filesystem_map;
|
||||
static v_file filesystem_romfs = nullptr;
|
||||
static VirtualFile filesystem_romfs = nullptr;
|
||||
|
||||
ResultCode RegisterFileSystem(std::unique_ptr<DeferredFilesystem>&& factory, Type type) {
|
||||
auto result = filesystem_map.emplace(type, std::move(factory));
|
||||
@@ -195,7 +195,7 @@ ResultCode RegisterFileSystem(std::unique_ptr<DeferredFilesystem>&& factory, Typ
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ResultCode RegisterRomFS(v_file filesystem) {
|
||||
ResultCode RegisterRomFS(VirtualFile filesystem) {
|
||||
ASSERT_MSG(filesystem_romfs == nullptr,
|
||||
"Tried to register more than one system with same id code");
|
||||
|
||||
@@ -205,7 +205,7 @@ ResultCode RegisterRomFS(v_file filesystem) {
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ResultVal<v_dir> OpenFileSystem(Type type) {
|
||||
ResultVal<VirtualDir> OpenFileSystem(Type type) {
|
||||
NGLOG_TRACE(Service_FS, "Opening FileSystem with type={}", static_cast<u32>(type));
|
||||
|
||||
auto itr = filesystem_map.find(type);
|
||||
@@ -217,7 +217,7 @@ ResultVal<v_dir> OpenFileSystem(Type type) {
|
||||
return MakeResult(itr->second->Get());
|
||||
}
|
||||
|
||||
ResultVal<v_file> OpenRomFS() {
|
||||
ResultVal<VirtualFile> OpenRomFS() {
|
||||
if (filesystem_romfs == nullptr)
|
||||
return ResultCode(-1);
|
||||
return MakeResult(filesystem_romfs);
|
||||
|
||||
@@ -35,10 +35,10 @@ enum class Type {
|
||||
// pointers and booleans. This makes using a VfsDirectory with switch services much easier and
|
||||
// avoids repetitive code.
|
||||
class VfsDirectoryServiceWrapper {
|
||||
v_dir backing;
|
||||
VirtualDir backing;
|
||||
|
||||
public:
|
||||
explicit VfsDirectoryServiceWrapper(v_dir backing);
|
||||
explicit VfsDirectoryServiceWrapper(VirtualDir backing);
|
||||
|
||||
/**
|
||||
* Get a descriptive name for the archive (e.g. "RomFS", "SaveData", etc.)
|
||||
@@ -103,14 +103,14 @@ public:
|
||||
* @param mode Mode to open the file with
|
||||
* @return Opened file, or error code
|
||||
*/
|
||||
ResultVal<v_file> OpenFile(const std::string& path, FileSys::Mode mode) const;
|
||||
ResultVal<VirtualFile> OpenFile(const std::string& path, FileSys::Mode mode) const;
|
||||
|
||||
/**
|
||||
* Open a directory specified by its path
|
||||
* @param path Path relative to the archive
|
||||
* @return Opened directory, or error code
|
||||
*/
|
||||
ResultVal<v_dir> OpenDirectory(const std::string& path);
|
||||
ResultVal<VirtualDir> OpenDirectory(const std::string& path);
|
||||
|
||||
/**
|
||||
* Get the free space
|
||||
@@ -127,14 +127,14 @@ public:
|
||||
|
||||
// A class that deferres the creation of a filesystem until a later time.
|
||||
// This is useful if construction depends on a variable not known when the filesystem is registered.
|
||||
// Construct this with a filesystem (v_dir) to avoid the deferrence feature or override the
|
||||
// Construct this with a filesystem (VirtualDir) to avoid the deferrence feature or override the
|
||||
// CreateFilesystem method which will be called on first use.
|
||||
struct DeferredFilesystem {
|
||||
DeferredFilesystem(){};
|
||||
|
||||
explicit DeferredFilesystem(v_dir vfs_directory) : fs(vfs_directory) {}
|
||||
explicit DeferredFilesystem(VirtualDir vfs_directory) : fs(vfs_directory) {}
|
||||
|
||||
v_dir Get() {
|
||||
VirtualDir Get() {
|
||||
if (fs == nullptr)
|
||||
fs = CreateFilesystem();
|
||||
|
||||
@@ -144,12 +144,12 @@ struct DeferredFilesystem {
|
||||
~DeferredFilesystem() = default;
|
||||
|
||||
protected:
|
||||
virtual v_dir CreateFilesystem() {
|
||||
virtual VirtualDir CreateFilesystem() {
|
||||
return fs;
|
||||
}
|
||||
|
||||
private:
|
||||
v_dir fs;
|
||||
VirtualDir fs;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -159,7 +159,7 @@ private:
|
||||
*/
|
||||
ResultCode RegisterFileSystem(std::unique_ptr<DeferredFilesystem>&& fs, Type type);
|
||||
|
||||
ResultCode RegisterRomFS(v_file fs);
|
||||
ResultCode RegisterRomFS(VirtualFile fs);
|
||||
|
||||
/**
|
||||
* Opens a file system
|
||||
@@ -167,9 +167,9 @@ ResultCode RegisterRomFS(v_file fs);
|
||||
* @param path Path to the file system, used with Binary paths
|
||||
* @return FileSys::FileSystemBackend interface to the file system
|
||||
*/
|
||||
ResultVal<v_dir> OpenFileSystem(Type type);
|
||||
ResultVal<VirtualDir> OpenFileSystem(Type type);
|
||||
|
||||
ResultVal<v_file> OpenRomFS();
|
||||
ResultVal<VirtualFile> OpenRomFS();
|
||||
|
||||
/**
|
||||
* Formats a file system
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Service::FileSystem {
|
||||
|
||||
class IStorage final : public ServiceFramework<IStorage> {
|
||||
public:
|
||||
IStorage(v_file backend_) : ServiceFramework("IStorage"), backend(backend_) {
|
||||
IStorage(VirtualFile backend_) : ServiceFramework("IStorage"), backend(backend_) {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IStorage::Read, "Read"}, {1, nullptr, "Write"}, {2, nullptr, "Flush"},
|
||||
{3, nullptr, "SetSize"}, {4, nullptr, "GetSize"}, {5, nullptr, "OperateRange"},
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
v_file backend;
|
||||
VirtualFile backend;
|
||||
|
||||
void Read(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
@@ -68,7 +68,7 @@ private:
|
||||
|
||||
class IFile final : public ServiceFramework<IFile> {
|
||||
public:
|
||||
explicit IFile(v_file backend_) : ServiceFramework("IFile"), backend(backend_) {
|
||||
explicit IFile(VirtualFile backend_) : ServiceFramework("IFile"), backend(backend_) {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IFile::Read, "Read"}, {1, &IFile::Write, "Write"},
|
||||
{2, &IFile::Flush, "Flush"}, {3, &IFile::SetSize, "SetSize"},
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
v_file backend;
|
||||
VirtualFile backend;
|
||||
|
||||
void Read(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
@@ -182,7 +182,7 @@ private:
|
||||
|
||||
class IDirectory final : public ServiceFramework<IDirectory> {
|
||||
public:
|
||||
explicit IDirectory(v_dir backend_) : ServiceFramework("IDirectory"), backend(backend_) {
|
||||
explicit IDirectory(VirtualDir backend_) : ServiceFramework("IDirectory"), backend(backend_) {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IDirectory::Read, "Read"},
|
||||
{1, &IDirectory::GetEntryCount, "GetEntryCount"},
|
||||
@@ -210,7 +210,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
v_dir backend;
|
||||
VirtualDir backend;
|
||||
std::vector<FileSys::Entry> entries;
|
||||
u64 next_entry_index = 0;
|
||||
|
||||
@@ -257,7 +257,7 @@ private:
|
||||
|
||||
class IFileSystem final : public ServiceFramework<IFileSystem> {
|
||||
public:
|
||||
explicit IFileSystem(v_dir backend)
|
||||
explicit IFileSystem(VirtualDir backend)
|
||||
: ServiceFramework("IFileSystem"), backend(std::move(backend)) {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IFileSystem::CreateFile, "CreateFile"},
|
||||
|
||||
@@ -29,7 +29,7 @@ private:
|
||||
void OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx);
|
||||
void OpenRomStorage(Kernel::HLERequestContext& ctx);
|
||||
|
||||
v_file romfs;
|
||||
VirtualFile romfs;
|
||||
};
|
||||
|
||||
} // namespace Service::FileSystem
|
||||
|
||||
@@ -45,10 +45,10 @@ static std::string FindRomFS(const std::string& directory) {
|
||||
return filepath_romfs;
|
||||
}
|
||||
|
||||
AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(v_file file)
|
||||
AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(VirtualFile file)
|
||||
: AppLoader(file) {}
|
||||
|
||||
FileType AppLoader_DeconstructedRomDirectory::IdentifyType(v_file file) {
|
||||
FileType AppLoader_DeconstructedRomDirectory::IdentifyType(VirtualFile file) {
|
||||
if (FileSys::IsDirectoryExeFS(file->GetContainingDirectory())) {
|
||||
return FileType::DeconstructedRomDirectory;
|
||||
}
|
||||
@@ -62,8 +62,8 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(
|
||||
return ResultStatus::ErrorAlreadyLoaded;
|
||||
}
|
||||
|
||||
const v_dir dir = file->GetContainingDirectory();
|
||||
const v_file npdm = dir->GetFile("main.npdm");
|
||||
const VirtualDir dir = file->GetContainingDirectory();
|
||||
const VirtualFile npdm = dir->GetFile("main.npdm");
|
||||
if (npdm == nullptr)
|
||||
return ResultStatus::ErrorInvalidFormat;
|
||||
|
||||
@@ -83,7 +83,7 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(
|
||||
for (const auto& module : {"rtld", "main", "subsdk0", "subsdk1", "subsdk2", "subsdk3",
|
||||
"subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) {
|
||||
const VAddr load_addr = next_load_addr;
|
||||
const v_file module_file = dir->GetFile(module);
|
||||
const VirtualFile module_file = dir->GetFile(module);
|
||||
if (module_file != nullptr)
|
||||
next_load_addr = AppLoader_NSO::LoadModule(module_file, load_addr);
|
||||
if (next_load_addr) {
|
||||
@@ -103,7 +103,7 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(
|
||||
|
||||
// Find the RomFS by searching for a ".romfs" file in this directory
|
||||
const auto& files = dir->GetFiles();
|
||||
const auto romfs_iter = std::find_if(files.begin(), files.end(), [](const v_file& file) {
|
||||
const auto romfs_iter = std::find_if(files.begin(), files.end(), [](const VirtualFile& file) {
|
||||
return file->GetName().find(".romfs") != std::string::npos;
|
||||
});
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ namespace Loader {
|
||||
*/
|
||||
class AppLoader_DeconstructedRomDirectory final : public AppLoader {
|
||||
public:
|
||||
AppLoader_DeconstructedRomDirectory(v_file main_file);
|
||||
AppLoader_DeconstructedRomDirectory(VirtualFile main_file);
|
||||
|
||||
/**
|
||||
* Returns the type of the file
|
||||
* @param file std::shared_ptr<VfsFile> open file
|
||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||
*/
|
||||
static FileType IdentifyType(v_file file);
|
||||
static FileType IdentifyType(VirtualFile file);
|
||||
|
||||
FileType GetFileType() override {
|
||||
return IdentifyType(file);
|
||||
|
||||
@@ -365,9 +365,9 @@ SectionID ElfReader::GetSectionByName(const char* name, int firstSection) const
|
||||
|
||||
namespace Loader {
|
||||
|
||||
AppLoader_ELF::AppLoader_ELF(v_file file) : AppLoader(file) {}
|
||||
AppLoader_ELF::AppLoader_ELF(VirtualFile file) : AppLoader(file) {}
|
||||
|
||||
FileType AppLoader_ELF::IdentifyType(v_file file) {
|
||||
FileType AppLoader_ELF::IdentifyType(VirtualFile file) {
|
||||
static constexpr u16 ELF_MACHINE_ARM{0x28};
|
||||
|
||||
u32 magic = 0;
|
||||
|
||||
@@ -16,14 +16,14 @@ namespace Loader {
|
||||
/// Loads an ELF/AXF file
|
||||
class AppLoader_ELF final : public AppLoader {
|
||||
public:
|
||||
AppLoader_ELF(v_file file);
|
||||
AppLoader_ELF(VirtualFile file);
|
||||
|
||||
/**
|
||||
* Returns the type of the file
|
||||
* @param file std::shared_ptr<VfsFile> open file
|
||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||
*/
|
||||
static FileType IdentifyType(v_file file);
|
||||
static FileType IdentifyType(VirtualFile file);
|
||||
|
||||
FileType GetFileType() override {
|
||||
return IdentifyType(file);
|
||||
|
||||
@@ -22,7 +22,7 @@ const std::initializer_list<Kernel::AddressMapping> default_address_mappings = {
|
||||
{0x1F000000, 0x600000, false}, // entire VRAM
|
||||
};
|
||||
|
||||
FileType IdentifyFile(v_file file) {
|
||||
FileType IdentifyFile(VirtualFile file) {
|
||||
FileType type;
|
||||
|
||||
#define CHECK_TYPE(loader) \
|
||||
@@ -42,7 +42,7 @@ FileType IdentifyFile(v_file file) {
|
||||
}
|
||||
|
||||
FileType IdentifyFile(const std::string& file_name) {
|
||||
return IdentifyFile(v_file(std::make_shared<FileSys::RealVfsFile>(file_name)));
|
||||
return IdentifyFile(VirtualFile(std::make_shared<FileSys::RealVfsFile>(file_name)));
|
||||
}
|
||||
|
||||
FileType GuessFromExtension(const std::string& extension_) {
|
||||
@@ -88,7 +88,7 @@ const char* GetFileTypeString(FileType type) {
|
||||
* @param filepath the file full path (with name)
|
||||
* @return std::unique_ptr<AppLoader> a pointer to a loader object; nullptr for unsupported type
|
||||
*/
|
||||
static std::unique_ptr<AppLoader> GetFileLoader(v_file file, FileType type) {
|
||||
static std::unique_ptr<AppLoader> GetFileLoader(VirtualFile file, FileType type) {
|
||||
switch (type) {
|
||||
|
||||
// Standard ELF file format.
|
||||
@@ -116,7 +116,7 @@ static std::unique_ptr<AppLoader> GetFileLoader(v_file file, FileType type) {
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<AppLoader> GetLoader(v_file file) {
|
||||
std::unique_ptr<AppLoader> GetLoader(VirtualFile file) {
|
||||
FileType type = IdentifyFile(file);
|
||||
FileType filename_type = GuessFromExtension(file->GetExtension());
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ enum class FileType {
|
||||
* @param file open file
|
||||
* @return FileType of file
|
||||
*/
|
||||
FileType IdentifyFile(v_file file);
|
||||
FileType IdentifyFile(VirtualFile file);
|
||||
|
||||
/**
|
||||
* Identifies the type of a bootable file based on the magic value in its header.
|
||||
@@ -79,7 +79,7 @@ enum class ResultStatus {
|
||||
/// Interface for loading an application
|
||||
class AppLoader : NonCopyable {
|
||||
public:
|
||||
AppLoader(v_file file) : file(std::move(file)) {}
|
||||
AppLoader(VirtualFile file) : file(std::move(file)) {}
|
||||
virtual ~AppLoader() {}
|
||||
|
||||
/**
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
* @param file The file containing the RomFS
|
||||
* @return ResultStatus result of function
|
||||
*/
|
||||
virtual ResultStatus ReadRomFS(v_file& dir) {
|
||||
virtual ResultStatus ReadRomFS(VirtualFile& dir) {
|
||||
return ResultStatus::ErrorNotImplemented;
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
* @param file The file containing the RomFS
|
||||
* @return ResultStatus result of function
|
||||
*/
|
||||
virtual ResultStatus ReadUpdateRomFS(v_file& file) {
|
||||
virtual ResultStatus ReadUpdateRomFS(VirtualFile& file) {
|
||||
return ResultStatus::ErrorNotImplemented;
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
v_file file;
|
||||
VirtualFile file;
|
||||
bool is_loaded = false;
|
||||
};
|
||||
|
||||
@@ -196,6 +196,6 @@ extern const std::initializer_list<Kernel::AddressMapping> default_address_mappi
|
||||
* @param filename String filename of bootable file
|
||||
* @return best loader for this file
|
||||
*/
|
||||
std::unique_ptr<AppLoader> GetLoader(v_file file);
|
||||
std::unique_ptr<AppLoader> GetLoader(VirtualFile file);
|
||||
|
||||
} // namespace Loader
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
namespace Loader {
|
||||
|
||||
AppLoader_NCA::AppLoader_NCA(v_file file) : AppLoader(file) {}
|
||||
AppLoader_NCA::AppLoader_NCA(VirtualFile file) : AppLoader(file) {}
|
||||
|
||||
FileType AppLoader_NCA::IdentifyType(v_file file) {
|
||||
FileType AppLoader_NCA::IdentifyType(VirtualFile file) {
|
||||
// TODO(DarkLordZach): Assuming everything is decrypted. Add crypto support.
|
||||
FileSys::NCAHeader header{};
|
||||
if (sizeof(FileSys::NCAHeader) != file->ReadObject(&header))
|
||||
|
||||
@@ -16,14 +16,14 @@ namespace Loader {
|
||||
/// Loads an NCA file
|
||||
class AppLoader_NCA final : public AppLoader {
|
||||
public:
|
||||
AppLoader_NCA(v_file file);
|
||||
AppLoader_NCA(VirtualFile file);
|
||||
|
||||
/**
|
||||
* Returns the type of the file
|
||||
* @param file std::shared_ptr<VfsFile> open file
|
||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||
*/
|
||||
static FileType IdentifyType(v_file file);
|
||||
static FileType IdentifyType(VirtualFile file);
|
||||
|
||||
FileType GetFileType() override {
|
||||
return IdentifyType(file);
|
||||
|
||||
@@ -47,9 +47,9 @@ struct ModHeader {
|
||||
};
|
||||
static_assert(sizeof(ModHeader) == 0x1c, "ModHeader has incorrect size.");
|
||||
|
||||
AppLoader_NRO::AppLoader_NRO(v_file file) : AppLoader(file) {}
|
||||
AppLoader_NRO::AppLoader_NRO(VirtualFile file) : AppLoader(file) {}
|
||||
|
||||
FileType AppLoader_NRO::IdentifyType(v_file file) {
|
||||
FileType AppLoader_NRO::IdentifyType(VirtualFile file) {
|
||||
// Read NSO header
|
||||
NroHeader nro_header{};
|
||||
if (sizeof(NroHeader) != file->ReadObject(&nro_header)) {
|
||||
@@ -65,7 +65,7 @@ static constexpr u32 PageAlignSize(u32 size) {
|
||||
return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK;
|
||||
}
|
||||
|
||||
bool AppLoader_NRO::LoadNro(v_file file, VAddr load_base) {
|
||||
bool AppLoader_NRO::LoadNro(VirtualFile file, VAddr load_base) {
|
||||
// Read NSO header
|
||||
NroHeader nro_header{};
|
||||
if (sizeof(NroHeader) != file->ReadObject(&nro_header)) {
|
||||
|
||||
@@ -15,14 +15,14 @@ namespace Loader {
|
||||
/// Loads an NRO file
|
||||
class AppLoader_NRO final : public AppLoader, Linker {
|
||||
public:
|
||||
AppLoader_NRO(v_file file);
|
||||
AppLoader_NRO(VirtualFile file);
|
||||
|
||||
/**
|
||||
* Returns the type of the file
|
||||
* @param file std::shared_ptr<VfsFile> open file
|
||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||
*/
|
||||
static FileType IdentifyType(v_file file);
|
||||
static FileType IdentifyType(VirtualFile file);
|
||||
|
||||
FileType GetFileType() override {
|
||||
return IdentifyType(file);
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
|
||||
|
||||
private:
|
||||
bool LoadNro(v_file file, VAddr load_base);
|
||||
bool LoadNro(VirtualFile file, VAddr load_base);
|
||||
};
|
||||
|
||||
} // namespace Loader
|
||||
|
||||
@@ -50,9 +50,9 @@ struct ModHeader {
|
||||
};
|
||||
static_assert(sizeof(ModHeader) == 0x1c, "ModHeader has incorrect size.");
|
||||
|
||||
AppLoader_NSO::AppLoader_NSO(v_file file) : AppLoader(file) {}
|
||||
AppLoader_NSO::AppLoader_NSO(VirtualFile file) : AppLoader(file) {}
|
||||
|
||||
FileType AppLoader_NSO::IdentifyType(v_file file) {
|
||||
FileType AppLoader_NSO::IdentifyType(VirtualFile file) {
|
||||
u32 magic = 0;
|
||||
file->ReadObject(&magic);
|
||||
|
||||
@@ -95,7 +95,7 @@ static constexpr u32 PageAlignSize(u32 size) {
|
||||
return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK;
|
||||
}
|
||||
|
||||
VAddr AppLoader_NSO::LoadModule(v_file file, VAddr load_base) {
|
||||
VAddr AppLoader_NSO::LoadModule(VirtualFile file, VAddr load_base) {
|
||||
if (file == nullptr)
|
||||
return {};
|
||||
|
||||
|
||||
@@ -15,20 +15,20 @@ namespace Loader {
|
||||
/// Loads an NSO file
|
||||
class AppLoader_NSO final : public AppLoader, Linker {
|
||||
public:
|
||||
AppLoader_NSO(v_file file);
|
||||
AppLoader_NSO(VirtualFile file);
|
||||
|
||||
/**
|
||||
* Returns the type of the file
|
||||
* @param file std::shared_ptr<VfsFile> open file
|
||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||
*/
|
||||
static FileType IdentifyType(v_file file);
|
||||
static FileType IdentifyType(VirtualFile file);
|
||||
|
||||
FileType GetFileType() override {
|
||||
return IdentifyType(file);
|
||||
}
|
||||
|
||||
static VAddr LoadModule(v_file file, VAddr load_base);
|
||||
static VAddr LoadModule(VirtualFile file, VAddr load_base);
|
||||
|
||||
ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user