Filesystem.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2008 Dolphin Emulator Project
  2. // Licensed under GPLv2+
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <cstddef>
  6. #include <cstring>
  7. #include <string>
  8. #include <vector>
  9. #include "Common/CommonTypes.h"
  10. namespace DiscIO
  11. {
  12. class IVolume;
  13. // file info of an FST entry
  14. struct SFileInfo
  15. {
  16. u64 m_NameOffset = 0u;
  17. u64 m_Offset = 0u;
  18. u64 m_FileSize = 0u;
  19. std::string m_FullPath;
  20. bool IsDirectory() const { return (m_NameOffset & 0xFF000000) != 0; }
  21. SFileInfo(u64 name_offset, u64 offset, u64 filesize) :
  22. m_NameOffset(name_offset),
  23. m_Offset(offset),
  24. m_FileSize(filesize)
  25. { }
  26. SFileInfo (SFileInfo const&) = default;
  27. SFileInfo () = default;
  28. };
  29. class IFileSystem
  30. {
  31. public:
  32. IFileSystem(const IVolume *_rVolume);
  33. virtual ~IFileSystem();
  34. virtual bool IsValid() const = 0;
  35. virtual const std::vector<SFileInfo>& GetFileList() = 0;
  36. virtual u64 GetFileSize(const std::string& _rFullPath) = 0;
  37. virtual u64 ReadFile(const std::string& _rFullPath, u8* _pBuffer, u64 _MaxBufferSize, u64 _OffsetInFile = 0) = 0;
  38. virtual bool ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename) = 0;
  39. virtual bool ExportApploader(const std::string& _rExportFolder) const = 0;
  40. virtual bool ExportDOL(const std::string& _rExportFolder) const = 0;
  41. virtual const std::string GetFileName(u64 _Address) = 0;
  42. virtual bool GetBootDOL(u8* &buffer, u32 DolSize) const = 0;
  43. virtual u32 GetBootDOLSize() const = 0;
  44. virtual const IVolume *GetVolume() const { return m_rVolume; }
  45. protected:
  46. const IVolume *m_rVolume;
  47. };
  48. IFileSystem* CreateFileSystem(const IVolume *_rVolume);
  49. } // namespace