/*
This example demonstrates how to use the GetLocationType to see find out whether the
file originated in the project path.
*/
var userpath = Application.InstallationPath( siUserPath ) ;
userpath = ConvertInstallationPathToString( XSIUtils.GetLocationType(userpath) );
Application.LogMessage( userpath ) ;
// Any file, directory below the user path (even if it doesn't exist yet) will
// be identified as being part of the user path
userpath += "/Application/Plugins/foo.vbs" ;
// Adjust slashes in case we are running on Windows
userpath = XSIUtils.ResolvePath( userpath ) ;
userpath = ConvertInstallationPathToString( XSIUtils.GetLocationType(userpath) );
Application.LogMessage( userpath ) ;
// Demonstrate how you could easily test if a scene file is part of the
// current project
var projpath = Application.InstallationPath( siProjectPath ) ;
projpath += "/Scenes/somescene.scn" ;
projpath = XSIUtils.ResolvePath( projpath ) ;
if ( XSIUtils.GetLocationType(projpath) == siProjectPath ) {
Application.LogMessage( "This scene is part of the current project" ) ;
}
// Expected results:
//INFO : siUserPath
//INFO : siProjectPath
//INFO : This scene is part of the current project
// Convenience function
function ConvertInstallationPathToString( in_location )
{
switch ( in_location ) {
case siProjectPath :
return "siProjectPath" ;
case siUserPath :
return "siUserPath" ;
case siWorkgroupPath :
return "siWorkgroupPath" ;
case siFactoryPath :
return "siFactoryPath" ;
case siAddonPath :
return "siAddonPath" ;
case siUserAddonPath :
return "siUserAddonPath" ;
case siWorkgroupAddonPath :
return "siWorkgroupAddonPath" ;
case siCustomPath :
return "siCustomPath" ;
default :
return "siUnknownPath" ;
}
} |