Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added bulk extraction tool #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions src/gmadd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main( int argc, char* argv[] )
//
// Create
//
if ( strCommand == "create" || File::IsFolder( strCommand ) )
if ( strCommand == "create" || File::IsFolder( strCommand ) && strCommand != "extractFolder")
{

BString strFolder = CommandLine::GetSwitch( "-folder", "" );
Expand Down Expand Up @@ -64,7 +64,40 @@ int main( int argc, char* argv[] )
BString strTarget = CommandLine::GetSwitch( "-out", "" );
return ExtractAddonFile( strFile, strTarget );
}


//
// Extract Folders
//
if ( strCommand == "extractfolder" )
{
BString strFolder = CommandLine::GetSwitch( "-folder", "" );

if ( strFolder == "" )
{
Output::Msg( "Missing -folder (the folder you want to extract)\n" );
exit( 1 );
}

BString strTarget = CommandLine::GetSwitch( "-out", "" );

//
// Get files to extract in folder
//
String::List files;
File::GetFilesInFolder( strFolder, files, false );

BOOTIL_FOREACH( f, files, String::List )
{
BString filenameWithExtension = f->c_str();
BString filename = filenameWithExtension;
String::File::StripExtension(filename);
if (String::File::IsFileExtension(filenameWithExtension, "gma"))
{
ExtractAddonFile(strFolder + "/" + filenameWithExtension, strTarget + "/" + filename);
}
}
return 0;
}
//
// Help
//
Expand All @@ -76,7 +109,8 @@ int main( int argc, char* argv[] )
Output::Msg("\tgmad.exe create -folder path/to/folder -out path/to/gma.gma\n");
Output::Msg("\tgmad.exe create -folder path/to/folder\n");
Output::Msg("\tgmad.exe extract -file path/to/gma.gma -out path/to/folder\n");
Output::Msg("\tgmad.exe extract -file path/to/gma.gma\n\n");
Output::Msg("\tgmad.exe extract -file path/to/gma.gma\n");
Output::Msg("\tgmad.exe extractFolder -folder path/to/gma/files/ -out path/to/folder\n\n");

Output::Msg("\tAdd -warninvalid to automatically skip invalid files\n\n");

Expand Down