Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Artic Base: Fix issue when 0 bytes are read from file #199

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/core/file_sys/archive_artic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,12 @@ ResultVal<std::size_t> ArticFileBackend::Read(u64 offset, std::size_t length, u8
return res;

auto read_buff = resp->GetResponseBuffer(0);
if (!read_buff.has_value())
return Result(-1);
size_t actually_read = read_buff->second;
size_t actually_read = 0;
if (read_buff.has_value()) {
actually_read = read_buff->second;
memcpy(buffer + read_amount, read_buff->first, actually_read);
}

memcpy(buffer + read_amount, read_buff->first, actually_read);
read_amount += actually_read;
if (actually_read != to_read)
break;
Expand Down
9 changes: 5 additions & 4 deletions src/core/file_sys/artic_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,12 @@ ResultVal<size_t> ArticCache::ReadFromArtic(s32 file_handle, u8* buffer, size_t
return res;

auto read_buff = resp->GetResponseBuffer(0);
if (!read_buff.has_value())
return Result(-1);
size_t actually_read = read_buff->second;
size_t actually_read = 0;
if (read_buff.has_value()) {
actually_read = read_buff->second;
memcpy(buffer + read_amount, read_buff->first, actually_read);
}

memcpy(buffer + read_amount, read_buff->first, actually_read);
read_amount += actually_read;
if (actually_read != to_read)
break;
Expand Down