ActorUtil: retry is simpler and more obvious with tail-calls
This commit is contained in:
+3
-12
@@ -34,18 +34,11 @@ void ActorUtil::Register( const RString& sClassName, CreateActorFn pfn )
|
|||||||
|
|
||||||
bool ActorUtil::ResolvePath( RString &sPath, const RString &sName )
|
bool ActorUtil::ResolvePath( RString &sPath, const RString &sName )
|
||||||
{
|
{
|
||||||
bool done = false;
|
|
||||||
// comply with VS C4701.
|
|
||||||
RageFileManager::FileType ft = RageFileManager::TYPE_NONE;
|
|
||||||
|
|
||||||
while (!done)
|
|
||||||
{
|
|
||||||
// Does this have to be collapsed every time?
|
|
||||||
CollapsePath( sPath );
|
CollapsePath( sPath );
|
||||||
|
|
||||||
// If we know this is an exact match, don't bother with the GetDirListing,
|
// If we know this is an exact match, don't bother with the GetDirListing,
|
||||||
// so "foo" doesn't partial match "foobar" if "foo" exists.
|
// so "foo" doesn't partial match "foobar" if "foo" exists.
|
||||||
ft = FILEMAN->GetFileType( sPath );
|
RageFileManager::FileType ft = FILEMAN->GetFileType( sPath );
|
||||||
if( ft != RageFileManager::TYPE_FILE && ft != RageFileManager::TYPE_DIR )
|
if( ft != RageFileManager::TYPE_FILE && ft != RageFileManager::TYPE_DIR )
|
||||||
{
|
{
|
||||||
vector<RString> asPaths;
|
vector<RString> asPaths;
|
||||||
@@ -61,7 +54,7 @@ bool ActorUtil::ResolvePath( RString &sPath, const RString &sName )
|
|||||||
break;
|
break;
|
||||||
case Dialog::retry:
|
case Dialog::retry:
|
||||||
FILEMAN->FlushDirCache();
|
FILEMAN->FlushDirCache();
|
||||||
continue;
|
return ResolvePath( sPath, sName );
|
||||||
case Dialog::ignore:
|
case Dialog::ignore:
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
@@ -82,7 +75,7 @@ bool ActorUtil::ResolvePath( RString &sPath, const RString &sName )
|
|||||||
break;
|
break;
|
||||||
case Dialog::retry:
|
case Dialog::retry:
|
||||||
FILEMAN->FlushDirCache();
|
FILEMAN->FlushDirCache();
|
||||||
continue;
|
return ResolvePath( sPath, sName );
|
||||||
case Dialog::ignore:
|
case Dialog::ignore:
|
||||||
asPaths.erase( asPaths.begin()+1, asPaths.end() );
|
asPaths.erase( asPaths.begin()+1, asPaths.end() );
|
||||||
break;
|
break;
|
||||||
@@ -93,8 +86,6 @@ bool ActorUtil::ResolvePath( RString &sPath, const RString &sName )
|
|||||||
|
|
||||||
sPath = asPaths[0];
|
sPath = asPaths[0];
|
||||||
}
|
}
|
||||||
done = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ft == RageFileManager::TYPE_DIR )
|
if( ft == RageFileManager::TYPE_DIR )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user