CISOBlob.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2008 Dolphin Emulator Project
  2. // Licensed under GPLv2+
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <cstdio>
  6. #include <string>
  7. #include "Common/CommonTypes.h"
  8. #include "Common/FileUtil.h"
  9. #include "DiscIO/Blob.h"
  10. namespace DiscIO
  11. {
  12. bool IsCISOBlob(const std::string& filename);
  13. static const u32 CISO_HEADER_SIZE = 0x8000;
  14. static const u32 CISO_MAP_SIZE = CISO_HEADER_SIZE - sizeof(u32) - sizeof(char) * 4;
  15. struct CISOHeader
  16. {
  17. // "CISO"
  18. char magic[4];
  19. // little endian
  20. u32 block_size;
  21. // 0=unused, 1=used, others=invalid
  22. u8 map[CISO_MAP_SIZE];
  23. };
  24. class CISOFileReader : public IBlobReader
  25. {
  26. public:
  27. static CISOFileReader* Create(const std::string& filename);
  28. u64 GetDataSize() const override;
  29. u64 GetRawSize() const override;
  30. bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
  31. private:
  32. CISOFileReader(std::FILE* file);
  33. typedef u16 MapType;
  34. static const MapType UNUSED_BLOCK_ID = -1;
  35. File::IOFile m_file;
  36. u64 m_size;
  37. u32 m_block_size;
  38. MapType m_ciso_map[CISO_MAP_SIZE];
  39. };
  40. } // namespace