Files
LibretroAdmin 30a5010c5a DVD: reads of a plain image copied straight from its mapping
A GameCube disc in a plain image is lent by the volume as it lies in
the mapped file. Such a read never goes to the DVD thread and has no
buffer: it starts by asking the OS to prefetch its pages, and when it
is due its bytes go from the mapping into emulated memory, or to the
DTK stream, in one copy. Compressed, encrypted and assembled images
keep the DVD thread.

A savestate stores pending lent reads as the results the DVD thread
would have made, so states keep their format, and a disc change turns
them into results before the old image goes.
2026-11-07 03:27:04 +01:00

44 lines
1.3 KiB
C++

// Copyright 2008 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
#include <string>
#include "Common/CommonTypes.h"
#include "Common/DirectIOFile.h"
#include "DiscIO/Blob.h"
namespace DiscIO
{
class PlainFileReader final : public BlobReader
{
public:
static std::unique_ptr<PlainFileReader> Create(File::DirectIOFile file);
BlobType GetBlobType() const override { return BlobType::PLAIN; }
std::unique_ptr<BlobReader> CopyReader() const override;
u64 GetRawSize() const override { return m_size; }
u64 GetDataSize() const override { return m_size; }
DataSizeType GetDataSizeType() const override { return DataSizeType::Accurate; }
u64 GetBlockSize() const override { return 0; }
bool HasFastRandomAccessInBlock() const override { return true; }
std::string GetCompressionMethod() const override { return {}; }
std::optional<int> GetCompressionLevel() const override { return std::nullopt; }
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
const u8* View(u64 offset, u64 size) const override { return m_file.View(offset, size); }
void Prefetch(u64 offset, u64 size) const override { m_file.Prefetch(offset, size); }
private:
PlainFileReader(File::DirectIOFile file);
File::DirectIOFile m_file;
u64 m_size;
};
} // namespace DiscIO