ResolvePath (XSIUtils)

Introduced

5.0

Description

Makes sure that all path separators are correct (that is, "\" on Windows and "/" on Linux) for the specified file path (which does not need to exist). This method also expands any environmental variables or Linktab rules. This is mainly useful for writing scripts that must work in a mixed-platform environment.

Scripting Syntax

XSIUtils.ResolvePath( [Path] )

C# Syntax

String XSIUtils.ResolvePath( String in_Path );

Parameters

Parameter

Type

Description

Path

String

Path to a directory or file.

Return Value

The resolved path as a String

Examples

1. JScript Example

/*
   This example demonstrates how to use the ResolvePath method on a
   nonexistent file.
*/
NewScene( null, false );

strPath = Application.InstallationPath( siUserPath ) ;
strPath += "/Application/Plugins" ;

// On Windows the "/" slash will be replaced by "\"
Application.LogMessage( XSIUtils.ResolvePath(strPath) ) ;

if ( Platform == "Win32" ){
   // Demonstrate how ResolvePath will still fix an invalid path
   strBogusPath = XSIUtils.ResolvePath( "C:\\bogusfolder/foo.txt" ) ;

   var fso = new ActiveXObject( "Scripting.FileSystemObject" ) ;

   if ( !fso.FileExists( strBogusPath ) ) {
       Application.LogMessage( strBogusPath + " does not exist" ) ;
   }
          } else {
   Application.LogMessage( XSIUtils.ResolvePath("/var/tmp\\foo.txt") );
}

// Expected results on Windows:
//INFO : C:\users\<USERNAME>\Softimage\<VERSION>\Application\Plugins
//INFO : C:\bogusfolder\foo.txt does not exist

2. VBScript Example

'
'  This example demonstrates how to resolve an environmental variable
'  that is part of a path.
'

if ( Platform = "Win32" ) then
   Application.LogMessage XSIUtils.ResolvePath("$USERPROFILE/foo.txt") 
end if

' Result on Windows will look similar to this:
'INFO C:\Documents and Settings\<name>\foo.txt

See Also

XSIUtils.Environment

XSIApplication.Platform

XSIUtils.EnsureFolderExists

XSIUtils.BuildPath



Autodesk Softimage v7.5