SplitFileBlob.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2023 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <memory>
  5. #include <optional>
  6. #include <string>
  7. #include <string_view>
  8. #include <vector>
  9. #include "Common/CommonTypes.h"
  10. #include "Common/IOFile.h"
  11. #include "DiscIO/Blob.h"
  12. namespace DiscIO
  13. {
  14. class SplitPlainFileReader final : public BlobReader
  15. {
  16. public:
  17. static std::unique_ptr<SplitPlainFileReader> Create(std::string_view first_file_path);
  18. BlobType GetBlobType() const override { return BlobType::SPLIT_PLAIN; }
  19. std::unique_ptr<BlobReader> CopyReader() const override;
  20. u64 GetRawSize() const override { return m_size; }
  21. u64 GetDataSize() const override { return m_size; }
  22. DataSizeType GetDataSizeType() const override { return DataSizeType::Accurate; }
  23. u64 GetBlockSize() const override { return 0; }
  24. bool HasFastRandomAccessInBlock() const override { return true; }
  25. std::string GetCompressionMethod() const override { return {}; }
  26. std::optional<int> GetCompressionLevel() const override { return std::nullopt; }
  27. bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
  28. private:
  29. struct SingleFile
  30. {
  31. File::IOFile file;
  32. u64 offset;
  33. u64 size;
  34. };
  35. SplitPlainFileReader(std::vector<SingleFile> m_files);
  36. std::vector<SingleFile> m_files;
  37. u64 m_size;
  38. };
  39. } // namespace DiscIO