Ver Fonte

added support for input files with no file extension

Noah há 4 anos atrás
pai
commit
f7731616af
1 ficheiros alterados com 14 adições e 4 exclusões
  1. 14 4
      src/main.cpp

+ 14 - 4
src/main.cpp

@@ -102,16 +102,26 @@ int main( int argc, char* argv[] )
     // use that as the output.
     if(!outFile.length())
     {
-        char *tmp = new char[inFile.length()];
-        stripExtension(inFile.c_str(), tmp, inFile.length());
+        // check for file extension and strip it if found
+        if(strchr(inFile.c_str(), '.'))
+        {
+            char *tmp = new char[inFile.length()];
+            stripExtension(inFile.c_str(), tmp, inFile.length());
 
-        outFile = tmp;
+            outFile = tmp;
+            delete [] tmp;
+        }
+        else
+        {
+            outFile = inFile;
+        }
+        
+        // set file extension for the output file
         if(bDecompile)
             outFile += ".tib";
         else
             outFile += ".8xp";
 
-        delete [] tmp;
     }
 
     // Make sure we have tokens to work with!