directory.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 "common/common_funcs.h"
  8. #include "common/common_types.h"
  9. ////////////////////////////////////////////////////////////////////////////////////////////////////
  10. // FileSys namespace
  11. namespace FileSys {
  12. enum class EntryType : u8 {
  13. Directory = 0,
  14. File = 1,
  15. };
  16. // Structure of a directory entry, from
  17. // http://switchbrew.org/index.php?title=Filesystem_services#DirectoryEntry
  18. struct Entry {
  19. Entry(std::string_view view, EntryType entry_type, u64 entry_size)
  20. : type{entry_type}, file_size{entry_size} {
  21. const std::size_t copy_size = view.copy(filename, std::size(filename) - 1);
  22. filename[copy_size] = '\0';
  23. }
  24. char filename[0x301];
  25. INSERT_PADDING_BYTES(3);
  26. EntryType type;
  27. INSERT_PADDING_BYTES(3);
  28. u64 file_size;
  29. };
  30. static_assert(sizeof(Entry) == 0x310, "Directory Entry struct isn't exactly 0x310 bytes long!");
  31. static_assert(offsetof(Entry, type) == 0x304, "Wrong offset for type in Entry.");
  32. static_assert(offsetof(Entry, file_size) == 0x308, "Wrong offset for file_size in Entry.");
  33. } // namespace FileSys