ReadFile EOF.

This commit is contained in:
Ben Vanik 2014-06-10 20:40:11 -07:00
parent ff8c03046a
commit 829b4f67bf
4 changed files with 8 additions and 1 deletions

View File

@ -63,6 +63,9 @@ X_STATUS DiscImageFile::ReadSync(
size_t* out_bytes_read) { size_t* out_bytes_read) {
GDFXEntry* gdfx_entry = entry_->gdfx_entry(); GDFXEntry* gdfx_entry = entry_->gdfx_entry();
xe_mmap_ref mmap = entry_->mmap(); xe_mmap_ref mmap = entry_->mmap();
if (byte_offset >= gdfx_entry->size) {
return X_STATUS_END_OF_FILE;
}
size_t real_offset = gdfx_entry->offset + byte_offset; size_t real_offset = gdfx_entry->offset + byte_offset;
size_t real_length = MIN(buffer_length, gdfx_entry->size - byte_offset); size_t real_length = MIN(buffer_length, gdfx_entry->size - byte_offset);
xe_copy_memory( xe_copy_memory(

View File

@ -71,6 +71,6 @@ X_STATUS HostPathFile::ReadSync(
*out_bytes_read = bytes_read; *out_bytes_read = bytes_read;
return X_STATUS_SUCCESS; return X_STATUS_SUCCESS;
} else { } else {
return X_STATUS_UNSUCCESSFUL; return X_STATUS_END_OF_FILE;
} }
} }

View File

@ -64,6 +64,9 @@ X_STATUS STFSContainerFile::ReadSync(
STFSEntry* stfs_entry = entry_->stfs_entry(); STFSEntry* stfs_entry = entry_->stfs_entry();
xe_mmap_ref mmap = entry_->mmap(); xe_mmap_ref mmap = entry_->mmap();
uint8_t* map_ptr = xe_mmap_get_addr(mmap); uint8_t* map_ptr = xe_mmap_get_addr(mmap);
if (byte_offset >= stfs_entry->size) {
return X_STATUS_END_OF_FILE;
}
// Each block is 4096. // Each block is 4096.
// Blocks may not be sequential, so we need to read by blocks and handle the // Blocks may not be sequential, so we need to read by blocks and handle the

View File

@ -43,6 +43,7 @@ typedef uint32_t X_STATUS;
#define X_STATUS_INVALID_HANDLE ((X_STATUS)0xC0000008L) #define X_STATUS_INVALID_HANDLE ((X_STATUS)0xC0000008L)
#define X_STATUS_INVALID_PARAMETER ((X_STATUS)0xC000000DL) #define X_STATUS_INVALID_PARAMETER ((X_STATUS)0xC000000DL)
#define X_STATUS_NO_SUCH_FILE ((X_STATUS)0xC000000FL) #define X_STATUS_NO_SUCH_FILE ((X_STATUS)0xC000000FL)
#define X_STATUS_END_OF_FILE ((X_STATUS)0xC0000011L)
#define X_STATUS_NO_MEMORY ((X_STATUS)0xC0000017L) #define X_STATUS_NO_MEMORY ((X_STATUS)0xC0000017L)
#define X_STATUS_ALREADY_COMMITTED ((X_STATUS)0xC0000021L) #define X_STATUS_ALREADY_COMMITTED ((X_STATUS)0xC0000021L)
#define X_STATUS_ACCESS_DENIED ((X_STATUS)0xC0000022L) #define X_STATUS_ACCESS_DENIED ((X_STATUS)0xC0000022L)