2022-04-23 08:59:50 +00:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-09-24 01:50:16 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "core/file_sys/vfs.h"
|
|
|
|
|
|
|
|
namespace FileSys {
|
|
|
|
|
|
|
|
struct RomFSBuildDirectoryContext;
|
|
|
|
struct RomFSBuildFileContext;
|
|
|
|
struct RomFSDirectoryEntry;
|
|
|
|
struct RomFSFileEntry;
|
|
|
|
|
|
|
|
class RomFSBuildContext {
|
|
|
|
public:
|
2018-10-02 12:56:56 +00:00
|
|
|
explicit RomFSBuildContext(VirtualDir base, VirtualDir ext = nullptr);
|
2018-09-24 01:50:16 +00:00
|
|
|
~RomFSBuildContext();
|
|
|
|
|
|
|
|
// This finalizes the context.
|
2023-11-28 03:27:57 +00:00
|
|
|
std::vector<std::pair<u64, VirtualFile>> Build();
|
2018-09-24 01:50:16 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
VirtualDir base;
|
2018-10-02 12:56:56 +00:00
|
|
|
VirtualDir ext;
|
2018-09-24 01:50:16 +00:00
|
|
|
std::shared_ptr<RomFSBuildDirectoryContext> root;
|
2023-11-28 03:27:57 +00:00
|
|
|
std::vector<std::shared_ptr<RomFSBuildDirectoryContext>> directories;
|
|
|
|
std::vector<std::shared_ptr<RomFSBuildFileContext>> files;
|
2018-09-24 01:50:16 +00:00
|
|
|
u64 num_dirs = 0;
|
|
|
|
u64 num_files = 0;
|
|
|
|
u64 dir_table_size = 0;
|
|
|
|
u64 file_table_size = 0;
|
|
|
|
u64 dir_hash_table_size = 0;
|
|
|
|
u64 file_hash_table_size = 0;
|
|
|
|
u64 file_partition_size = 0;
|
|
|
|
|
2021-05-02 06:34:40 +00:00
|
|
|
void VisitDirectory(VirtualDir filesys, VirtualDir ext_dir,
|
2018-10-02 12:56:56 +00:00
|
|
|
std::shared_ptr<RomFSBuildDirectoryContext> parent);
|
2018-09-24 01:50:16 +00:00
|
|
|
|
|
|
|
bool AddDirectory(std::shared_ptr<RomFSBuildDirectoryContext> parent_dir_ctx,
|
|
|
|
std::shared_ptr<RomFSBuildDirectoryContext> dir_ctx);
|
|
|
|
bool AddFile(std::shared_ptr<RomFSBuildDirectoryContext> parent_dir_ctx,
|
|
|
|
std::shared_ptr<RomFSBuildFileContext> file_ctx);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace FileSys
|