Skip to content

Commit

Permalink
On --import check for valid file types
Browse files Browse the repository at this point in the history
  • Loading branch information
zonkmachine committed May 4, 2016
1 parent 1a9a9a0 commit 6ae87f4
Showing 1 changed file with 46 additions and 5 deletions.
51 changes: 46 additions & 5 deletions src/core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ int main( int argc, char * * argv )
bool renderTracks = false;
QString fileToLoad, fileToImport, renderOut, profilerOutputFile, configFile;

// QString fileToLoad = "";
// QString fileToImport = "";
// QString renderOut = "";
// QString profilerOutputFile = "";

// first of two command-line parsing stages
for( int i = 1; i < argc; ++i )
{
Expand Down Expand Up @@ -566,17 +571,53 @@ int main( int argc, char * * argv )
}

// Test file argument before continuing
QFileInfo fileInfo( fileToLoad );
QFileInfo fileInfoLoad( fileToLoad );
QFileInfo fileInfoImport( fileToImport );
if( !fileToLoad.isEmpty() )
{
if ( !fileInfo.exists() || !fileInfo.isFile() )
if( !fileInfoLoad.exists() )
{
printf( "The file %s does not exist!\n",
fileToLoad.toStdString().c_str() );
exit( 1 );
}
else if( fileInfoLoad.isDir() )
{
printf( "%s is a directory!\n",
fileToLoad.toStdString().c_str() );
exit( 1 );
}
else if( !( fileInfoLoad.suffix() == "mmp" ||
fileInfoLoad.suffix() == "mmpz" ) )
{
printf( "%s is not an LMMS project file!\n",
fileToLoad.toStdString().c_str() );
exit( 1 );
}
}
else if( !fileToImport.isEmpty() )
{
if( !fileInfoImport.exists() )
{
printf( "The file %s does not exist!\n",
fileToImport.toStdString().c_str() );
exit( 1 );
}
else if( fileInfoImport.isDir() )
{
printf("The file %s does not exist!\n", fileToLoad.toStdString().c_str());
printf( "%s is a directory!\n",
fileToImport.toStdString().c_str() );
exit( 1 );
}
else if( ! ( fileInfo.suffix() == "mmp" || fileInfo.suffix() == "mmpz" ) )
else if( !(
fileInfoImport.suffix() == "mid" ||
fileInfoImport.suffix() == "midi" ||
fileInfoImport.suffix() == "rmi" ||
fileInfoImport.suffix() == "flp" ||
fileInfoImport.suffix() == "h2song" ) )
{
printf("%s is not an LMMS project file!\n", fileToLoad.toStdString().c_str());
printf( ".%s is not a filetype that LMMS can import!\n",
fileInfoImport.suffix().toStdString().c_str() );
exit( 1 );
}
}
Expand Down

0 comments on commit 6ae87f4

Please sign in to comment.