8 changes: 4 additions & 4 deletions Source/Core/Core/IOS/WFS/WFSSRV.cpp
Expand Up @@ -290,14 +290,14 @@ std::optional<IPCReply> WFSSRVDevice::IOCtl(const IOCtlRequest& request)
const u64 previous_position = fd_obj->file.Tell();
if (absolute)
{
fd_obj->file.Seek(position, SEEK_SET);
fd_obj->file.Seek(position, File::SeekOrigin::Begin);
}
size_t read_bytes;
fd_obj->file.ReadArray(Memory::GetPointer(addr), size, &read_bytes);
// TODO(wfs): Handle read errors.
if (absolute)
{
fd_obj->file.Seek(previous_position, SEEK_SET);
fd_obj->file.Seek(previous_position, File::SeekOrigin::Begin);
}
else
{
Expand Down Expand Up @@ -331,13 +331,13 @@ std::optional<IPCReply> WFSSRVDevice::IOCtl(const IOCtlRequest& request)
const u64 previous_position = fd_obj->file.Tell();
if (absolute)
{
fd_obj->file.Seek(position, SEEK_SET);
fd_obj->file.Seek(position, File::SeekOrigin::Begin);
}
fd_obj->file.WriteArray(Memory::GetPointer(addr), size);
// TODO(wfs): Handle write errors.
if (absolute)
{
fd_obj->file.Seek(previous_position, SEEK_SET);
fd_obj->file.Seek(previous_position, File::SeekOrigin::Begin);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Movie.cpp
Expand Up @@ -1021,7 +1021,7 @@ void LoadInput(const std::string& movie_path)
{
s_rerecords++;
tmpHeader.numRerecords = s_rerecords;
t_record.Seek(0, SEEK_SET);
t_record.Seek(0, File::SeekOrigin::Begin);
t_record.WriteArray(&tmpHeader, 1);
}

Expand Down
12 changes: 8 additions & 4 deletions Source/Core/DiscIO/CISOBlob.cpp
Expand Up @@ -18,7 +18,7 @@ CISOFileReader::CISOFileReader(File::IOFile file) : m_file(std::move(file))
m_size = m_file.GetSize();

CISOHeader header;
m_file.Seek(0, SEEK_SET);
m_file.Seek(0, File::SeekOrigin::Begin);
m_file.ReadArray(&header, 1);

m_block_size = header.block_size;
Expand All @@ -31,8 +31,11 @@ CISOFileReader::CISOFileReader(File::IOFile file) : m_file(std::move(file))
std::unique_ptr<CISOFileReader> CISOFileReader::Create(File::IOFile file)
{
CISOHeader header;
if (file.Seek(0, SEEK_SET) && file.ReadArray(&header, 1) && header.magic == CISO_MAGIC)
if (file.Seek(0, File::SeekOrigin::Begin) && file.ReadArray(&header, 1) &&
header.magic == CISO_MAGIC)
{
return std::unique_ptr<CISOFileReader>(new CISOFileReader(std::move(file)));
}

return nullptr;
}
Expand Down Expand Up @@ -63,9 +66,10 @@ bool CISOFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
// calculate the base address
u64 const file_off = CISO_HEADER_SIZE + m_ciso_map[block] * (u64)m_block_size + data_offset;

if (!(m_file.Seek(file_off, SEEK_SET) && m_file.ReadArray(out_ptr, bytes_to_read)))
if (!(m_file.Seek(file_off, File::SeekOrigin::Begin) &&
m_file.ReadArray(out_ptr, bytes_to_read)))
{
m_file.Clear();
m_file.ClearError();
return false;
}
}
Expand Down
16 changes: 8 additions & 8 deletions Source/Core/DiscIO/CompressedBlob.cpp
Expand Up @@ -38,7 +38,7 @@ CompressedBlobReader::CompressedBlobReader(File::IOFile file, const std::string&
: m_file(std::move(file)), m_file_name(filename)
{
m_file_size = m_file.GetSize();
m_file.Seek(0, SEEK_SET);
m_file.Seek(0, File::SeekOrigin::Begin);
m_file.ReadArray(&m_header, 1);

SetSectorSize(m_header.block_size);
Expand Down Expand Up @@ -104,12 +104,12 @@ bool CompressedBlobReader::GetBlock(u64 block_num, u8* out_ptr)
// clear unused part of zlib buffer. maybe this can be deleted when it works fully.
memset(&m_zlib_buffer[comp_block_size], 0, m_zlib_buffer.size() - comp_block_size);

m_file.Seek(offset, SEEK_SET);
m_file.Seek(offset, File::SeekOrigin::Begin);
if (!m_file.ReadBytes(m_zlib_buffer.data(), comp_block_size))
{
ERROR_LOG_FMT(DISCIO, "The disc image \"{}\" is truncated, some of the data is missing.",
m_file_name);
m_file.Clear();
m_file.ClearError();
return false;
}

Expand Down Expand Up @@ -301,9 +301,9 @@ bool ConvertToGCZ(BlobReader* infile, const std::string& infile_path,
std::vector<u32> hashes(header.num_blocks);

// seek past the header (we will write it at the end)
outfile.Seek(sizeof(CompressedBlobHeader), SEEK_CUR);
outfile.Seek(sizeof(CompressedBlobHeader), File::SeekOrigin::Current);
// seek past the offset and hash tables (we will write them at the end)
outfile.Seek((sizeof(u64) + sizeof(u32)) * header.num_blocks, SEEK_CUR);
outfile.Seek((sizeof(u64) + sizeof(u32)) * header.num_blocks, File::SeekOrigin::Current);

// Now we are ready to write compressed data!
u64 inpos = 0;
Expand Down Expand Up @@ -361,7 +361,7 @@ bool ConvertToGCZ(BlobReader* infile, const std::string& infile_path,
else
{
// Okay, go back and fill in headers
outfile.Seek(0, SEEK_SET);
outfile.Seek(0, File::SeekOrigin::Begin);
outfile.WriteArray(&header, 1);
outfile.WriteArray(offsets.data(), header.num_blocks);
outfile.WriteArray(hashes.data(), header.num_blocks);
Expand All @@ -385,11 +385,11 @@ bool ConvertToGCZ(BlobReader* infile, const std::string& infile_path,
bool IsGCZBlob(File::IOFile& file)
{
const u64 position = file.Tell();
if (!file.Seek(0, SEEK_SET))
if (!file.Seek(0, File::SeekOrigin::Begin))
return false;
CompressedBlobHeader header;
bool is_gcz = file.ReadArray(&header, 1) && header.magic_cookie == GCZ_MAGIC;
file.Seek(position, SEEK_SET);
file.Seek(position, File::SeekOrigin::Begin);
return is_gcz;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DiscIO/DirectoryBlob.cpp
Expand Up @@ -98,7 +98,7 @@ bool DiscContent::Read(u64* offset, u64* length, u8** buffer) const
{
const auto& content = std::get<ContentFile>(m_content_source);
File::IOFile file(content.m_filename, "rb");
if (!file.Seek(content.m_offset + offset_in_content, SEEK_SET) ||
if (!file.Seek(content.m_offset + offset_in_content, File::SeekOrigin::Begin) ||
!file.ReadBytes(*buffer, bytes_to_read))
{
return false;
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DiscIO/DriveBlob.cpp
Expand Up @@ -150,10 +150,10 @@ bool DriveReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8* o
}
return bytes_read == GetSectorSize() * num_blocks;
#else
m_file.Seek(GetSectorSize() * block_num, SEEK_SET);
m_file.Seek(GetSectorSize() * block_num, File::SeekOrigin::Begin);
if (m_file.ReadBytes(out_ptr, num_blocks * GetSectorSize()))
return true;
m_file.Clear();
m_file.ClearError();
return false;
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DiscIO/FileBlob.cpp
Expand Up @@ -30,13 +30,13 @@ std::unique_ptr<PlainFileReader> PlainFileReader::Create(File::IOFile file)

bool PlainFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
{
if (m_file.Seek(offset, SEEK_SET) && m_file.ReadBytes(out_ptr, nbytes))
if (m_file.Seek(offset, File::SeekOrigin::Begin) && m_file.ReadBytes(out_ptr, nbytes))
{
return true;
}
else
{
m_file.Clear();
m_file.ClearError();
return false;
}
}
Expand Down
4 changes: 3 additions & 1 deletion Source/Core/DiscIO/NANDImporter.cpp
Expand Up @@ -71,7 +71,9 @@ bool NANDImporter::ReadNANDBin(const std::string& path_to_bin,
m_update_callback();

file.ReadBytes(&m_nand[i * NAND_BLOCK_SIZE], NAND_BLOCK_SIZE);
file.Seek(NAND_ECC_BLOCK_SIZE, SEEK_CUR); // We don't care about the ECC blocks

// We don't care about the ECC blocks
file.Seek(NAND_ECC_BLOCK_SIZE, File::SeekOrigin::Current);
}

m_nand_keys.resize(NAND_KEYS_SIZE);
Expand Down
17 changes: 12 additions & 5 deletions Source/Core/DiscIO/TGCBlob.cpp
Expand Up @@ -48,24 +48,30 @@ namespace DiscIO
std::unique_ptr<TGCFileReader> TGCFileReader::Create(File::IOFile file)
{
TGCHeader header;
if (file.Seek(0, SEEK_SET) && file.ReadArray(&header, 1) && header.magic == TGC_MAGIC)
if (file.Seek(0, File::SeekOrigin::Begin) && file.ReadArray(&header, 1) &&
header.magic == TGC_MAGIC)
{
return std::unique_ptr<TGCFileReader>(new TGCFileReader(std::move(file)));
}

return nullptr;
}

TGCFileReader::TGCFileReader(File::IOFile file) : m_file(std::move(file))
{
m_file.Seek(0, SEEK_SET);
m_file.Seek(0, File::SeekOrigin::Begin);
m_file.ReadArray(&m_header, 1);

m_size = m_file.GetSize();

const u32 fst_offset = Common::swap32(m_header.fst_real_offset);
const u32 fst_size = Common::swap32(m_header.fst_size);
m_fst.resize(fst_size);
if (!m_file.Seek(fst_offset, SEEK_SET) || !m_file.ReadBytes(m_fst.data(), m_fst.size()))
if (!m_file.Seek(fst_offset, File::SeekOrigin::Begin) ||
!m_file.ReadBytes(m_fst.data(), m_fst.size()))
{
m_fst.clear();
}

constexpr size_t FST_ENTRY_SIZE = 12;
if (m_fst.size() < FST_ENTRY_SIZE)
Expand Down Expand Up @@ -101,7 +107,8 @@ bool TGCFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
{
const u32 tgc_header_size = Common::swap32(m_header.tgc_header_size);

if (m_file.Seek(offset + tgc_header_size, SEEK_SET) && m_file.ReadBytes(out_ptr, nbytes))
if (m_file.Seek(offset + tgc_header_size, File::SeekOrigin::Begin) &&
m_file.ReadBytes(out_ptr, nbytes))
{
const u32 replacement_dol_offset = SubtractBE32(m_header.dol_real_offset, tgc_header_size);
const u32 replacement_fst_offset = SubtractBE32(m_header.fst_real_offset, tgc_header_size);
Expand All @@ -114,7 +121,7 @@ bool TGCFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
return true;
}

m_file.Clear();
m_file.ClearError();
return false;
}

Expand Down
12 changes: 6 additions & 6 deletions Source/Core/DiscIO/WIABlob.cpp
Expand Up @@ -87,7 +87,7 @@ WIARVZFileReader<RVZ>::~WIARVZFileReader() = default;
template <bool RVZ>
bool WIARVZFileReader<RVZ>::Initialize(const std::string& path)
{
if (!m_file.Seek(0, SEEK_SET) || !m_file.ReadArray(&m_header_1, 1))
if (!m_file.Seek(0, File::SeekOrigin::Begin) || !m_file.ReadArray(&m_header_1, 1))
return false;

if ((!RVZ && m_header_1.magic != WIA_MAGIC) || (RVZ && m_header_1.magic != RVZ_MAGIC))
Expand Down Expand Up @@ -160,7 +160,7 @@ bool WIARVZFileReader<RVZ>::Initialize(const std::string& path)
const size_t number_of_partition_entries = Common::swap32(m_header_2.number_of_partition_entries);
const size_t partition_entry_size = Common::swap32(m_header_2.partition_entry_size);
std::vector<u8> partition_entries(partition_entry_size * number_of_partition_entries);
if (!m_file.Seek(Common::swap64(m_header_2.partition_entries_offset), SEEK_SET))
if (!m_file.Seek(Common::swap64(m_header_2.partition_entries_offset), File::SeekOrigin::Begin))
return false;
if (!m_file.ReadBytes(partition_entries.data(), partition_entries.size()))
return false;
Expand Down Expand Up @@ -686,7 +686,7 @@ bool WIARVZFileReader<RVZ>::Chunk::Read(u64 offset, u64 size, u8* out_ptr)
return false;
}

if (!m_file->Seek(m_offset_in_file, SEEK_SET))
if (!m_file->Seek(m_offset_in_file, File::SeekOrigin::Begin))
return false;
if (!m_file->ReadBytes(m_in.data.data() + m_in.bytes_written, bytes_to_read))
return false;
Expand Down Expand Up @@ -1716,7 +1716,7 @@ bool WIARVZFileReader<RVZ>::WriteHeader(File::IOFile* file, const u8* data, size
{
WARN_LOG_FMT(DISCIO,
"Headers did not fit in the allocated space. Writing to end of file instead");
if (!file->Seek(0, SEEK_END))
if (!file->Seek(0, File::SeekOrigin::End))
return false;
*bytes_written = file->Tell();
}
Expand Down Expand Up @@ -1949,7 +1949,7 @@ WIARVZFileReader<RVZ>::Convert(BlobReader* infile, const VolumeDisc* infile_volu
return ConversionResultCode::InternalError;

bytes_written = sizeof(WIAHeader1) + sizeof(WIAHeader2);
if (!outfile->Seek(sizeof(WIAHeader1) + sizeof(WIAHeader2), SEEK_SET))
if (!outfile->Seek(sizeof(WIAHeader1) + sizeof(WIAHeader2), File::SeekOrigin::Begin))
return ConversionResultCode::WriteFailed;

u64 partition_entries_offset;
Expand Down Expand Up @@ -2018,7 +2018,7 @@ WIARVZFileReader<RVZ>::Convert(BlobReader* infile, const VolumeDisc* infile_volu
mbedtls_sha1_ret(reinterpret_cast<const u8*>(&header_1), offsetof(WIAHeader1, header_1_hash),
header_1.header_1_hash.data());

if (!outfile->Seek(0, SEEK_SET))
if (!outfile->Seek(0, File::SeekOrigin::Begin))
return ConversionResultCode::WriteFailed;

if (!outfile->WriteArray(&header_1, 1))
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/DiscIO/WbfsBlob.cpp
Expand Up @@ -37,7 +37,7 @@ WbfsFileReader::WbfsFileReader(File::IOFile file, const std::string& path)
// Grab disc info (assume slot 0, checked in ReadHeader())
m_wlba_table.resize(m_blocks_per_disc);
m_files[0].file.Seek(m_hd_sector_size + WII_DISC_HEADER_SIZE /*+ i * m_disc_info_size*/,
SEEK_SET);
File::SeekOrigin::Begin);
m_files[0].file.ReadBytes(m_wlba_table.data(), m_blocks_per_disc * sizeof(u16));
for (size_t i = 0; i < m_blocks_per_disc; i++)
m_wlba_table[i] = Common::swap16(m_wlba_table[i]);
Expand Down Expand Up @@ -86,7 +86,7 @@ bool WbfsFileReader::AddFileToList(File::IOFile file)
bool WbfsFileReader::ReadHeader()
{
// Read hd size info
m_files[0].file.Seek(0, SEEK_SET);
m_files[0].file.Seek(0, File::SeekOrigin::Begin);
m_files[0].file.ReadBytes(&m_header, sizeof(WbfsHeader));
if (m_header.magic != WBFS_MAGIC)
return false;
Expand Down Expand Up @@ -127,7 +127,7 @@ bool WbfsFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)

if (!data_file.ReadBytes(out_ptr, read_size))
{
data_file.Clear();
data_file.ClearError();
return false;
}

Expand All @@ -152,7 +152,7 @@ File::IOFile& WbfsFileReader::SeekToCluster(u64 offset, u64* available)
{
if (final_address < (file_entry.base_address + file_entry.size))
{
file_entry.file.Seek(final_address - file_entry.base_address, SEEK_SET);
file_entry.file.Seek(final_address - file_entry.base_address, File::SeekOrigin::Begin);
if (available)
{
u64 till_end_of_file = file_entry.size - (final_address - file_entry.base_address);
Expand All @@ -168,7 +168,7 @@ File::IOFile& WbfsFileReader::SeekToCluster(u64 offset, u64* available)
ERROR_LOG_FMT(DISCIO, "Read beyond end of disc");
if (available)
*available = 0;
m_files[0].file.Seek(0, SEEK_SET);
m_files[0].file.Seek(0, File::SeekOrigin::Begin);
return m_files[0].file;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DiscIO/WiiSaveBanner.cpp
Expand Up @@ -60,7 +60,7 @@ std::vector<u32> WiiSaveBanner::GetBanner(u32* width, u32* height) const
*height = 0;

File::IOFile file(m_path, "rb");
if (!file.Seek(sizeof(Header), SEEK_SET))
if (!file.Seek(sizeof(Header), File::SeekOrigin::Begin))
return std::vector<u32>();

std::vector<u16> banner_data(BANNER_WIDTH * BANNER_HEIGHT);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoCommon/HiresTextures_DDSLoader.cpp
Expand Up @@ -447,7 +447,7 @@ bool HiresTexture::LoadDDSTexture(HiresTexture* tex, const std::string& filename

// Read first mip level, as it may have a custom pitch.
Level first_level;
if (!file.Seek(info.first_mip_offset, SEEK_SET) ||
if (!file.Seek(info.first_mip_offset, File::SeekOrigin::Begin) ||
!ReadMipLevel(&first_level, file, filename, 0, info, info.width, info.height,
info.first_mip_row_length, info.first_mip_size))
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoCommon/ShaderCache.cpp
Expand Up @@ -772,7 +772,7 @@ void ShaderCache::LoadPipelineUIDCache()

// We open the file for reading and writing, so we must seek to the end before writing.
if (uid_file_valid)
uid_file_valid = m_gx_pipeline_uid_cache_file.Seek(expected_size, SEEK_SET);
uid_file_valid = m_gx_pipeline_uid_cache_file.Seek(expected_size, File::SeekOrigin::Begin);
}

// If the file is invalid, close it. We re-open and truncate it below.
Expand Down