v5.0
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.
String XSIUtils.ResolvePath( String in_Path ); |
oString = XSIUtils.ResolvePath( [Path] ); |
The resolved path as a String
Parameter | Type | Description |
---|---|---|
Path | String | Path to a directory or file. |
/* 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 |
' ' 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 |