directory.h 1.2 KB

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