summaryrefslogtreecommitdiffstats
path: root/zutils.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2017-04-10 15:19:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2017-04-10 15:19:00 +0000
commit6e01d7d8f65270f174ed4f161a5292aa5b89be0c (patch)
treeb73c1aad1d4cf13aad03fb2764f8123f266d27b4 /zutils.cc
parentReleasing debian version 1.5-5. (diff)
downloadzutils-6e01d7d8f65270f174ed4f161a5292aa5b89be0c.tar.xz
zutils-6e01d7d8f65270f174ed4f161a5292aa5b89be0c.zip
Merging upstream version 1.6.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'zutils.cc')
-rw-r--r--zutils.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/zutils.cc b/zutils.cc
index 460ceec..536a5bd 100644
--- a/zutils.cc
+++ b/zutils.cc
@@ -1,5 +1,5 @@
/* Zutils - Utilities dealing with compressed files
- Copyright (C) 2009-2016 Antonio Diaz Diaz.
+ Copyright (C) 2009-2017 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -112,7 +112,9 @@ int writeblock( const int fd, const uint8_t * const buf, const int size )
}
-bool feed_data( const int infd, const int outfd,
+// Empty filename means stdin.
+//
+bool feed_data( const std::string & filename, const int infd, const int outfd,
const uint8_t * magic_data, const int magic_size )
{
if( magic_size && writeblock( outfd, magic_data, magic_size ) != magic_size )
@@ -123,7 +125,8 @@ bool feed_data( const int infd, const int outfd,
{
const int size = readblock( infd, buffer, buffer_size );
if( size != buffer_size && errno )
- { show_error( "Read error", errno ); return false; }
+ { const char * const name = filename.empty() ? "-" : filename.c_str();
+ show_file_error( name, "Read error", errno ); return false; }
if( size > 0 && writeblock( outfd, buffer, size ) != size )
{ show_error( "Write error", errno ); return false; }
if( size < buffer_size ) break;
@@ -156,7 +159,8 @@ bool good_status( const Children & children, const bool finished )
}
-bool set_data_feeder( int * const infdp, Children & children, int format_index )
+bool set_data_feeder( const std::string & filename, int * const infdp,
+ Children & children, int format_index )
{
const uint8_t * magic_data = 0;
int magic_size = 0;
@@ -177,7 +181,7 @@ bool set_data_feeder( int * const infdp, Children & children, int format_index )
{
if( close( fda[0] ) != 0 ||
close( fda2[0] ) != 0 || close( fda2[1] ) != 0 ||
- !feed_data( old_infd, fda[1], magic_data, magic_size ) )
+ !feed_data( filename, old_infd, fda[1], magic_data, magic_size ) )
_exit( 2 );
if( close( fda[1] ) != 0 )
{ show_close_error(); _exit( 2 ); }
@@ -226,7 +230,7 @@ bool set_data_feeder( int * const infdp, Children & children, int format_index )
if( pid == 0 ) // child (feeder)
{
if( close( fda[0] ) != 0 ||
- !feed_data( old_infd, fda[1], magic_data, magic_size ) )
+ !feed_data( filename, old_infd, fda[1], magic_data, magic_size ) )
_exit( 2 );
if( close( fda[1] ) != 0 )
{ show_close_error(); _exit( 2 ); }