Skip to content

Commit

Permalink
[librvth] reader_plain_open(): Don't fail if the file is 0 bytes.
Browse files Browse the repository at this point in the history
This happens when creating new files for extraction.

This fixes a regression from commit 13b0070.
([librvth] ref_get_size(): New function to get a file's size.)
  • Loading branch information
GerbilSoft committed Sep 18, 2018
1 parent 50ac70f commit fedd31a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/librvth/reader_plain.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ Reader *reader_plain_open(RefFile *file, uint32_t lba_start, uint32_t lba_len)
reader->vtbl = &reader_plain_vtable;

// Get the file size.
errno = 0;
filesize = ref_get_size(reader->file);
if (filesize <= 0) {
// Empty file or seek error.
if (filesize < 0) {
// Seek error.
// NOTE: Not failing on empty file, since that happens
// when creating a new file to extract an image.
err = errno;
if (err == 0) {
err = EIO;
Expand Down

0 comments on commit fedd31a

Please sign in to comment.