More goto removals.
Note: unsure if the path must be collapsed each time.
This commit is contained in:
+49
-41
@@ -34,58 +34,66 @@ void ActorUtil::Register( const RString& sClassName, CreateActorFn pfn )
|
|||||||
|
|
||||||
bool ActorUtil::ResolvePath( RString &sPath, const RString &sName )
|
bool ActorUtil::ResolvePath( RString &sPath, const RString &sName )
|
||||||
{
|
{
|
||||||
retry:
|
bool done = false;
|
||||||
CollapsePath( sPath );
|
// comply with VS C4701.
|
||||||
|
RageFileManager::FileType ft = RageFileManager::TYPE_NONE;
|
||||||
|
|
||||||
// If we know this is an exact match, don't bother with the GetDirListing,
|
while (!done)
|
||||||
// so "foo" doesn't partial match "foobar" if "foo" exists.
|
|
||||||
RageFileManager::FileType ft = FILEMAN->GetFileType( sPath );
|
|
||||||
if( ft != RageFileManager::TYPE_FILE && ft != RageFileManager::TYPE_DIR )
|
|
||||||
{
|
{
|
||||||
vector<RString> asPaths;
|
// Does this have to be collapsed every time?
|
||||||
GetDirListing( sPath + "*", asPaths, false, true ); // return path too
|
CollapsePath( sPath );
|
||||||
|
|
||||||
if( asPaths.empty() )
|
// If we know this is an exact match, don't bother with the GetDirListing,
|
||||||
|
// so "foo" doesn't partial match "foobar" if "foo" exists.
|
||||||
|
ft = FILEMAN->GetFileType( sPath );
|
||||||
|
if( ft != RageFileManager::TYPE_FILE && ft != RageFileManager::TYPE_DIR )
|
||||||
{
|
{
|
||||||
RString sError = ssprintf( "%s: references a file \"%s\" which doesn't exist", sName.c_str(), sPath.c_str() );
|
vector<RString> asPaths;
|
||||||
switch( Dialog::AbortRetryIgnore( sError, "BROKEN_FILE_REFERENCE" ) )
|
GetDirListing( sPath + "*", asPaths, false, true ); // return path too
|
||||||
|
|
||||||
|
if( asPaths.empty() )
|
||||||
{
|
{
|
||||||
case Dialog::abort:
|
RString sError = ssprintf( "%s: references a file \"%s\" which doesn't exist", sName.c_str(), sPath.c_str() );
|
||||||
RageException::Throw( "%s", sError.c_str() );
|
switch( Dialog::AbortRetryIgnore( sError, "BROKEN_FILE_REFERENCE" ) )
|
||||||
break;
|
{
|
||||||
case Dialog::retry:
|
case Dialog::abort:
|
||||||
FILEMAN->FlushDirCache();
|
RageException::Throw( "%s", sError.c_str() );
|
||||||
goto retry;
|
break;
|
||||||
case Dialog::ignore:
|
case Dialog::retry:
|
||||||
return false;
|
FILEMAN->FlushDirCache();
|
||||||
default:
|
continue;
|
||||||
FAIL_M("Invalid response to Abort/Retry/Ignore dialog");
|
case Dialog::ignore:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
FAIL_M("Invalid response to Abort/Retry/Ignore dialog");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
THEME->FilterFileLanguages( asPaths );
|
THEME->FilterFileLanguages( asPaths );
|
||||||
|
|
||||||
if( asPaths.size() > 1 )
|
if( asPaths.size() > 1 )
|
||||||
{
|
|
||||||
RString sError = ssprintf( "%s: references a file \"%s\" which has multiple matches", sName.c_str(), sPath.c_str() );
|
|
||||||
sError += "\n" + join( "\n", asPaths );
|
|
||||||
switch( Dialog::AbortRetryIgnore( sError, "BROKEN_FILE_REFERENCE" ) )
|
|
||||||
{
|
{
|
||||||
case Dialog::abort:
|
RString sError = ssprintf( "%s: references a file \"%s\" which has multiple matches", sName.c_str(), sPath.c_str() );
|
||||||
RageException::Throw( "%s", sError.c_str() );
|
sError += "\n" + join( "\n", asPaths );
|
||||||
break;
|
switch( Dialog::AbortRetryIgnore( sError, "BROKEN_FILE_REFERENCE" ) )
|
||||||
case Dialog::retry:
|
{
|
||||||
FILEMAN->FlushDirCache();
|
case Dialog::abort:
|
||||||
goto retry;
|
RageException::Throw( "%s", sError.c_str() );
|
||||||
case Dialog::ignore:
|
break;
|
||||||
asPaths.erase( asPaths.begin()+1, asPaths.end() );
|
case Dialog::retry:
|
||||||
break;
|
FILEMAN->FlushDirCache();
|
||||||
default:
|
continue;
|
||||||
FAIL_M("Invalid response to Abort/Retry/Ignore dialog");
|
case Dialog::ignore:
|
||||||
|
asPaths.erase( asPaths.begin()+1, asPaths.end() );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
FAIL_M("Invalid response to Abort/Retry/Ignore dialog");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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