@ -233,7 +233,17 @@ int extract(std::unique_ptr<Bsa::BSAFile>& bsa, Arguments& info)
std : : string extractPath = info . extractfile ;
std : : string extractPath = info . extractfile ;
Misc : : StringUtils : : replaceAll ( extractPath , " \\ " , " / " ) ;
Misc : : StringUtils : : replaceAll ( extractPath , " \\ " , " / " ) ;
if ( ! bsa - > exists ( archivePath . c_str ( ) ) )
Files : : IStreamPtr stream ;
// Get a stream for the file to extract
for ( auto it = bsa - > getList ( ) . rbegin ( ) ; it ! = bsa - > getList ( ) . rend ( ) ; + + it )
{
if ( Misc : : StringUtils : : ciEqual ( std : : string ( it - > name ( ) ) , archivePath ) )
{
stream = bsa - > getFile ( & * it ) ;
break ;
}
}
if ( ! stream )
{
{
std : : cout < < " ERROR: file ' " < < archivePath < < " ' not found \n " ;
std : : cout < < " ERROR: file ' " < < archivePath < < " ' not found \n " ;
std : : cout < < " In archive: " < < info . filename < < std : : endl ;
std : : cout < < " In archive: " < < info . filename < < std : : endl ;
@ -260,9 +270,6 @@ int extract(std::unique_ptr<Bsa::BSAFile>& bsa, Arguments& info)
return 3 ;
return 3 ;
}
}
// Get a stream for the file to extract
Files : : IStreamPtr stream = bsa - > getFile ( archivePath . c_str ( ) ) ;
bfs : : ofstream out ( target , std : : ios : : binary ) ;
bfs : : ofstream out ( target , std : : ios : : binary ) ;
// Write the file to disk
// Write the file to disk
@ -296,8 +303,7 @@ int extractAll(std::unique_ptr<Bsa::BSAFile>& bsa, Arguments& info)
}
}
// Get a stream for the file to extract
// Get a stream for the file to extract
// (inefficient because getFile iter on the list again)
Files : : IStreamPtr data = bsa - > getFile ( & file ) ;
Files : : IStreamPtr data = bsa - > getFile ( file . name ( ) ) ;
bfs : : ofstream out ( target , std : : ios : : binary ) ;
bfs : : ofstream out ( target , std : : ios : : binary ) ;
// Write the file to disk
// Write the file to disk