fsmitm_romfsbuild.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2018 Atmosphère-NX
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. /*
  17. * Adapted by DarkLordZach for use/interaction with yuzu
  18. *
  19. * Modifications Copyright 2018 yuzu emulator team
  20. * Licensed under GPLv2 or any later version
  21. * Refer to the license.txt file included.
  22. */
  23. #pragma once
  24. #include <map>
  25. #include <memory>
  26. #include <string>
  27. #include "common/common_types.h"
  28. #include "core/file_sys/vfs.h"
  29. namespace FileSys {
  30. struct RomFSBuildDirectoryContext;
  31. struct RomFSBuildFileContext;
  32. struct RomFSDirectoryEntry;
  33. struct RomFSFileEntry;
  34. class RomFSBuildContext {
  35. public:
  36. explicit RomFSBuildContext(VirtualDir base, VirtualDir ext = nullptr);
  37. ~RomFSBuildContext();
  38. // This finalizes the context.
  39. std::multimap<u64, VirtualFile> Build();
  40. private:
  41. VirtualDir base;
  42. VirtualDir ext;
  43. std::shared_ptr<RomFSBuildDirectoryContext> root;
  44. std::map<std::string, std::shared_ptr<RomFSBuildDirectoryContext>, std::less<>> directories;
  45. std::map<std::string, std::shared_ptr<RomFSBuildFileContext>, std::less<>> files;
  46. u64 num_dirs = 0;
  47. u64 num_files = 0;
  48. u64 dir_table_size = 0;
  49. u64 file_table_size = 0;
  50. u64 dir_hash_table_size = 0;
  51. u64 file_hash_table_size = 0;
  52. u64 file_partition_size = 0;
  53. void VisitDirectory(VirtualDir filesys, VirtualDir ext_dir,
  54. std::shared_ptr<RomFSBuildDirectoryContext> parent);
  55. bool AddDirectory(std::shared_ptr<RomFSBuildDirectoryContext> parent_dir_ctx,
  56. std::shared_ptr<RomFSBuildDirectoryContext> dir_ctx);
  57. bool AddFile(std::shared_ptr<RomFSBuildDirectoryContext> parent_dir_ctx,
  58. std::shared_ptr<RomFSBuildFileContext> file_ctx);
  59. };
  60. } // namespace FileSys