XSIUtils.ResolvePath

導入

v5.0

詳細

指定されたファイルパス(存在していなくてもかまいません)に対し、すべてのパスセパレータ(Windows のセパレータは「¥」、LinuX のセパレータは「/」)が適切であることを確認します。このメソッドは、すべての環境変数またはLinktabルールを拡張します。主に、プラットフォームが混在する環境で使用するスクリプトを記述する際に使用します。

スクリプト 構文

oString = XSIUtils.ResolvePath( [Path] );

戻り値

解決されたパス(String

パラメータ

パラメータ タイプ 詳細
Path String ディレクトリまたはファイルのパス

1. JScript の例

/*
        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 の例

'
'       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

関連項目

XSIUtils.Environment XSIApplication.Platform XSIUtils.EnsureFolderExists XSIUtils.BuildPath