diff options
author | kientzle <kientzle@FreeBSD.org> | 2005-03-13 01:51:16 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2005-03-13 01:51:16 +0000 |
commit | 3d74129d7e1f125cb4b8893cff77845f536d78d2 (patch) | |
tree | 7137f40ff4ed6e273a7e52faadc131353fbb5722 /lib/libarchive/archive_read_open_file.c | |
parent | b1a33585f7e3a73f28d73b3cf27028c6f971a61f (diff) | |
download | FreeBSD-src-3d74129d7e1f125cb4b8893cff77845f536d78d2.zip FreeBSD-src-3d74129d7e1f125cb4b8893cff77845f536d78d2.tar.gz |
Better error messages on read and file-open errors.
Diffstat (limited to 'lib/libarchive/archive_read_open_file.c')
-rw-r--r-- | lib/libarchive/archive_read_open_file.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/libarchive/archive_read_open_file.c b/lib/libarchive/archive_read_open_file.c index 57ac6c2..ea8ebbd 100644 --- a/lib/libarchive/archive_read_open_file.c +++ b/lib/libarchive/archive_read_open_file.c @@ -99,8 +99,11 @@ file_open(struct archive *a, void *client_data) /* Remember mode so close can decide whether to flush. */ mine->st_mode = st.st_mode; } else { - archive_set_error(a, errno, "Can't stat '%s'", - mine->filename); + if (mine->filename[0] == '\0') + archive_set_error(a, errno, "Can't stat stdin"); + else + archive_set_error(a, errno, "Can't stat '%s'", + mine->filename); return (ARCHIVE_FATAL); } return (0); @@ -110,10 +113,19 @@ static ssize_t file_read(struct archive *a, void *client_data, const void **buff) { struct read_file_data *mine = client_data; + ssize_t bytes_read; (void)a; /* UNUSED */ *buff = mine->buffer; - return (read(mine->fd, mine->buffer, mine->block_size)); + bytes_read = read(mine->fd, mine->buffer, mine->block_size); + if (bytes_read < 0) { + if (mine->filename[0] == '\0') + archive_set_error(a, errno, "Error reading stdin"); + else + archive_set_error(a, errno, "Error reading '%s'", + mine->filename); + } + return (bytes_read); } static int |