1010int main (int argc, char * argv[])
1111{
1212 const char * fname;
13+ const char * inner_fname = 0 ;
1314 if (argc > 1 ) {
1415 fname = argv[1 ];
16+ if (argc > 2 )
17+ inner_fname = argv[2 ];
1518 } else {
1619 printf (" You must specify path to archive!\n " );
1720 return 1 ;
@@ -22,16 +25,17 @@ int main(int argc, char* argv[])
2225
2326 lString32Collection list;
2427 LVStreamRef stream = LVOpenFileStream ( fname, LVOM_READ );
28+ LVContainerRef arc;
2529 if ( !stream.isNull () ) {
26- LVContainerRef arc = LVOpenArchieve (stream);
30+ arc = LVOpenArchieve (stream);
2731 if ( !arc.isNull () ) {
2832 // convert
2933 for ( int i=0 ; i<arc->GetObjectCount (); i++ ) {
3034 const LVContainerItemInfo * item = arc->GetObjectInfo (i);
3135 if ( item->IsContainer ())
3236 continue ;
3337 list.add ( item->GetName () );
34- list.add ( lString32::itoa (item->GetSize ()) );
38+ list.add ( lString32::itoa ((lUInt64) item->GetSize ()) );
3539 }
3640 } else {
3741 printf (" Failed to open archive!\n " );
@@ -42,11 +46,54 @@ int main(int argc, char* argv[])
4246 return 1 ;
4347 }
4448
49+ #if 0
50+ if (!arc.isNull()) {
51+ if (NULL != inner_fname) {
52+ printf("Open file inside archive...\n");
53+ lString32 inner_fname32 = LocalToUnicode(lString8(inner_fname));
54+ LVStreamRef inner_stream = arc->OpenStream(inner_fname32.c_str(), LVOM_READ);
55+ if (!inner_stream.isNull()) {
56+ printf(" ok\n");
57+ LVStreamRef out_stream = LVOpenFileStream(inner_fname32.c_str(), LVOM_WRITE);
58+ if (!out_stream.isNull()) {
59+ printf("output file opened...\n");
60+ lUInt8 buff[4096];
61+ lvsize_t ReadSize;
62+ lvsize_t WriteSize;
63+ while (true) {
64+ if (inner_stream->Read(buff, 4096, &ReadSize) != LVERR_OK) {
65+ printf("Read error!\n");
66+ break;
67+ }
68+ if (0 == ReadSize) {
69+ break;
70+ }
71+ if (out_stream->Write(buff, ReadSize, &WriteSize) != LVERR_OK) {
72+ printf("Write error!\n");
73+ break;
74+ }
75+ }
76+ } else {
77+ printf("Failed top open output file!\n");
78+ }
79+ } else {
80+ printf(" failed\n");
81+ }
82+ } else {
83+ printf("Inner filename must be specified from command line!\n");
84+ }
85+ }
86+ #endif
87+
88+ #if 1
4589 printf (" Archive contents:\n " );
4690 for (int i = 0 ; i < list.length ()/2 ; i++) {
4791 lString32 name = list[i*2 ];
48- int size = lString32 (list[i*2 +1 ]).atoi ();
49- printf (" %s: %u\n " , LCSTR (name), size);
92+ lInt64 size;
93+ if (!list[i*2 +1 ].atoi (size))
94+ size = 0 ;
95+ printf (" %s: %lld\n " , LCSTR (name), size);
5096 }
97+ #endif
5198 return 0 ;
5299}
0 commit comments