directory.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <cstddef>
  5. #include "common/common_funcs.h"
  6. #include "common/common_types.h"
  7. ////////////////////////////////////////////////////////////////////////////////////////////////////
  8. // FileSys namespace
  9. namespace FileSys {
  10. enum class EntryType : u8 {
  11. Directory = 0,
  12. File = 1,
  13. };
  14. // Structure of a directory entry, from
  15. // http://switchbrew.org/index.php?title=Filesystem_services#DirectoryEntry
  16. struct Entry {
  17. Entry(std::string_view view, EntryType entry_type, u64 entry_size)
  18. : type{entry_type}, file_size{entry_size} {
  19. const std::size_t copy_size = view.copy(filename, std::size(filename) - 1);
  20. filename[copy_size] = '\0';
  21. }
  22. char filename[0x301];
  23. INSERT_PADDING_BYTES(3);
  24. EntryType type;
  25. INSERT_PADDING_BYTES(3);
  26. u64 file_size;
  27. };
  28. static_assert(sizeof(Entry) == 0x310, "Directory Entry struct isn't exactly 0x310 bytes long!");
  29. static_assert(offsetof(Entry, type) == 0x304, "Wrong offset for type in Entry.");
  30. static_assert(offsetof(Entry, file_size) == 0x308, "Wrong offset for file_size in Entry.");
  31. } // namespace FileSys