diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2025-10-29 20:26:47 -0500 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2025-11-09 03:08:14 -0600 |
| commit | 239330017c97fa3f6b4b2670ab570e822d6affb0 (patch) | |
| tree | fca744551834dc4788eab4d32bb969073b3a2157 /Source/Core/DiscIO/FileBlob.cpp | |
| parent | b98acb9a37a80b22a0da1bee7be0c4c44adadb56 (diff) | |
DiscIO: Make all BlobReader implementations use DirectIOFile to make CopyReader functionality thread safe.
Diffstat (limited to 'Source/Core/DiscIO/FileBlob.cpp')
| -rw-r--r-- | Source/Core/DiscIO/FileBlob.cpp | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/Source/Core/DiscIO/FileBlob.cpp b/Source/Core/DiscIO/FileBlob.cpp index 9ba572ea77..3a30e2a255 100644 --- a/Source/Core/DiscIO/FileBlob.cpp +++ b/Source/Core/DiscIO/FileBlob.cpp @@ -15,14 +15,14 @@ namespace DiscIO { -PlainFileReader::PlainFileReader(File::IOFile file) : m_file(std::move(file)) +PlainFileReader::PlainFileReader(File::DirectIOFile file) : m_file(std::move(file)) { m_size = m_file.GetSize(); } -std::unique_ptr<PlainFileReader> PlainFileReader::Create(File::IOFile file) +std::unique_ptr<PlainFileReader> PlainFileReader::Create(File::DirectIOFile file) { - if (file) + if (file.IsOpen()) return std::unique_ptr<PlainFileReader>(new PlainFileReader(std::move(file))); return nullptr; @@ -30,20 +30,12 @@ std::unique_ptr<PlainFileReader> PlainFileReader::Create(File::IOFile file) std::unique_ptr<BlobReader> PlainFileReader::CopyReader() const { - return Create(m_file.Duplicate("rb")); + return Create(m_file); } bool PlainFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr) { - if (m_file.Seek(offset, File::SeekOrigin::Begin) && m_file.ReadBytes(out_ptr, nbytes)) - { - return true; - } - else - { - m_file.ClearError(); - return false; - } + return m_file.OffsetRead(offset, out_ptr, nbytes); } bool ConvertToPlain(BlobReader* infile, const std::string& infile_path, @@ -51,8 +43,8 @@ bool ConvertToPlain(BlobReader* infile, const std::string& infile_path, { ASSERT(infile->GetDataSizeType() == DataSizeType::Accurate); - File::IOFile outfile(outfile_path, "wb"); - if (!outfile) + File::DirectIOFile outfile(outfile_path, File::AccessMode::Write); + if (!outfile.IsOpen()) { PanicAlertFmtT( "Failed to open the output file \"{0}\".\n" @@ -99,7 +91,7 @@ bool ConvertToPlain(BlobReader* infile, const std::string& infile_path, success = false; break; } - if (!outfile.WriteBytes(buffer.data(), sz)) + if (!outfile.Write(buffer.data(), sz)) { PanicAlertFmtT("Failed to write the output file \"{0}\".\n" "Check that you have enough space available on the target drive.", |
