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 Jan 29, 2016
1 parent 2098e5d commit 469117d
Showing 1 changed file with 45 additions and 6 deletions.
51 changes: 45 additions & 6 deletions src/core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ int main( int argc, char * * argv )
bool allowRoot = false;
bool renderLoop = false;
bool renderTracks = false;
QString fileToLoad, fileToImport, renderOut, profilerOutputFile;
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 @@ -537,17 +540,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());
printf( "The file %s does not exist!\n",
fileToLoad.toStdString().c_str() );
exit( 1 );
}
else if( ! ( fileInfo.suffix() == "mmp" || fileInfo.suffix() == "mmpz" ) )
else if( fileInfoLoad.isDir() )
{
printf("%s is not an LMMS project file!\n", fileToLoad.toStdString().c_str());
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( "%s is a directory!\n",
fileToImport.toStdString().c_str() );
exit( 1 );
}
else if( !(
fileInfoImport.suffix() == "mid" ||
fileInfoImport.suffix() == "midi" ||
fileInfoImport.suffix() == "rmi" ||
fileInfoImport.suffix() == "flp" ||
fileInfoImport.suffix() == "h2song" ) )
{
printf( ".%s is not a filetype that LMMS can import!\n",
fileInfoImport.suffix().toStdString().c_str() );
exit( 1 );
}
}
Expand Down

0 comments on commit 469117d

Please sign in to comment.