[0.3.x] fixed: run script without .py extension

git-svn-id: https://pykd.svn.codeplex.com/svn@89655 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\EreTIk_cp 2015-01-20 09:35:31 +00:00 committed by Mikhail I. Izmestev
parent dd2138393c
commit d7672c3ffe
2 changed files with 14 additions and 12 deletions

View File

@ -247,16 +247,18 @@ void PykdExt::printUsage()
std::string PykdExt::getScriptFileName( const std::string &scriptName ) std::string PykdExt::getScriptFileName( const std::string &scriptName )
{ {
bool fileHasPyExt = false; std::string scriptFileName = findScript( scriptName );
if ( scriptName.length() > 3 ) if ( scriptFileName.empty() && (scriptName.rfind(".py") != scriptName.length() - 3) )
fileHasPyExt = scriptName.rfind(".py") == scriptName.length() - 3; scriptFileName = findScript( scriptName + ".py" );
std::string fullFileName = scriptName; return scriptFileName;
}
if (!fileHasPyExt) ///////////////////////////////////////////////////////////////////////////////
fullFileName += ".py";
std::string PykdExt::findScript( const std::string &fullFileName )
{
if ( GetFileAttributesA(fullFileName.c_str()) != INVALID_FILE_ATTRIBUTES ) if ( GetFileAttributesA(fullFileName.c_str()) != INVALID_FILE_ATTRIBUTES )
return fullFileName; return fullFileName;
@ -287,8 +289,7 @@ std::string PykdExt::getScriptFileName( const std::string &scriptName )
if (bufSize > 0) if (bufSize > 0)
{ {
fullFileName = std::string(&fullFileNameCStr[0]); return std::string(&fullFileNameCStr[0]);
return fullFileName;
} }
} }
} }

View File

@ -25,6 +25,7 @@ private:
virtual void tearDown(); virtual void tearDown();
std::string getScriptFileName( const std::string &scriptName ); std::string getScriptFileName( const std::string &scriptName );
std::string findScript( const std::string &fullFileName );
std::vector<std::string> m_paths; std::vector<std::string> m_paths;