summaryrefslogtreecommitdiffstats
path: root/list.cc
diff options
context:
space:
mode:
Diffstat (limited to 'list.cc')
-rw-r--r--list.cc58
1 files changed, 26 insertions, 32 deletions
diff --git a/list.cc b/list.cc
index d3e4908..cc8c6da 100644
--- a/list.cc
+++ b/list.cc
@@ -1,18 +1,18 @@
-/* Plzip - Massively parallel implementation of lzip
- Copyright (C) 2009-2019 Antonio Diaz Diaz.
+/* Plzip - Massively parallel implementation of lzip
+ Copyright (C) 2009-2021 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
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ 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
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _FILE_OFFSET_BITS 64
@@ -21,7 +21,6 @@
#include <cstring>
#include <string>
#include <vector>
-#include <pthread.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/stat.h>
@@ -37,11 +36,11 @@ void list_line( const unsigned long long uncomp_size,
const char * const input_filename )
{
if( uncomp_size > 0 )
- std::printf( "%15llu %15llu %6.2f%% %s\n", uncomp_size, comp_size,
+ std::printf( "%14llu %14llu %6.2f%% %s\n", uncomp_size, comp_size,
100.0 - ( ( 100.0 * comp_size ) / uncomp_size ),
input_filename );
else
- std::printf( "%15llu %15llu -INF%% %s\n", uncomp_size, comp_size,
+ std::printf( "%14llu %14llu -INF%% %s\n", uncomp_size, comp_size,
input_filename );
}
@@ -63,15 +62,15 @@ int list_files( const std::vector< std::string > & filenames,
from_stdin ? "(stdin)" : filenames[i].c_str();
struct stat in_stats; // not used
const int infd = from_stdin ? STDIN_FILENO :
- open_instream( input_filename, &in_stats, true, true );
- if( infd < 0 ) { if( retval < 1 ) retval = 1; continue; }
+ open_instream( input_filename, &in_stats, false, true );
+ if( infd < 0 ) { set_retval( retval, 1 ); continue; }
const Lzip_index lzip_index( infd, ignore_trailing, loose_trailing );
close( infd );
if( lzip_index.retval() != 0 )
{
show_file_error( input_filename, lzip_index.error().c_str() );
- if( retval < lzip_index.retval() ) retval = lzip_index.retval();
+ set_retval( retval, lzip_index.retval() );
continue;
}
if( verbosity >= 0 )
@@ -79,32 +78,27 @@ int list_files( const std::vector< std::string > & filenames,
const unsigned long long udata_size = lzip_index.udata_size();
const unsigned long long cdata_size = lzip_index.cdata_size();
total_comp += cdata_size; total_uncomp += udata_size; ++files;
+ const long members = lzip_index.members();
if( first_post )
{
first_post = false;
if( verbosity >= 1 ) std::fputs( " dict memb trail ", stdout );
- std::fputs( " uncompressed compressed saved name\n", stdout );
+ std::fputs( " uncompressed compressed saved name\n", stdout );
}
if( verbosity >= 1 )
- {
- unsigned dictionary_size = 0;
- for( long i = 0; i < lzip_index.members(); ++i )
- dictionary_size =
- std::max( dictionary_size, lzip_index.dictionary_size( i ) );
- const long long trailing_size = lzip_index.file_size() - cdata_size;
- std::printf( "%s %5ld %6lld ", format_ds( dictionary_size ),
- lzip_index.members(), trailing_size );
- }
+ std::printf( "%s %5ld %6lld ",
+ format_ds( lzip_index.dictionary_size() ), members,
+ lzip_index.file_size() - cdata_size );
list_line( udata_size, cdata_size, input_filename );
- if( verbosity >= 2 && lzip_index.members() > 1 )
+ if( verbosity >= 2 && members > 1 )
{
- std::fputs( " member data_pos data_size member_pos member_size\n", stdout );
- for( long i = 0; i < lzip_index.members(); ++i )
+ std::fputs( " member data_pos data_size member_pos member_size\n", stdout );
+ for( long i = 0; i < members; ++i )
{
const Block & db = lzip_index.dblock( i );
const Block & mb = lzip_index.mblock( i );
- std::printf( "%5ld %15llu %15llu %15llu %15llu\n",
+ std::printf( "%6ld %14llu %14llu %14llu %14llu\n",
i + 1, db.pos(), db.size(), mb.pos(), mb.size() );
}
first_post = true; // reprint heading after list of members