mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[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:
parent
dd2138393c
commit
d7672c3ffe
@ -117,7 +117,7 @@ KDLIB_EXT_COMMAND_METHOD_IMPL(PykdExt, py)
|
|||||||
std::string scriptFileName;
|
std::string scriptFileName;
|
||||||
if ( args.size() > 0 )
|
if ( args.size() > 0 )
|
||||||
{
|
{
|
||||||
scriptFileName = getScriptFileName( args[0] );
|
scriptFileName = getScriptFileName( args[0] );
|
||||||
|
|
||||||
if ( scriptFileName.empty() )
|
if ( scriptFileName.empty() )
|
||||||
{
|
{
|
||||||
@ -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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user