2 // Use Rar_Extractor to open "test.rar" and list it and possibly extract files.
4 const int extract
= 0; // 0: just list files, 1: extract
6 #include "unrar/Rar_Extractor.h"
11 static void check_error( const char* str
)
15 fprintf( stderr
, "Error: %s\n", str
);
24 check_error( file
.open( "test.rar" ) );
28 check_error( rar
.open( &file
) );
30 // If not extracting, use faster scan-only mode
34 // Iterate over each item in archive until end is reached
36 while ( (error
= rar
.next()) != end_of_rar
)
40 if ( !rar
.info().is_file
)
42 printf( "Directory %s\n", rar
.info().name
);
46 printf( "File %s\n", rar
.info().name
);
52 check_error( out
.open( rar
.info().name
) );
55 error
= rar
.extract( out
);
57 fprintf( stderr
, "Error: %s\n", error
);