Static Public Member Functions
CUtils Class Reference

## Detailed Description

This is an intrinsic object that provides general utility methods.

Since:
  5.1

`#include <xsi_utils.h>`

List of all members.

## Static Public Member Functions
static CString | ResolvePath (const CString &in_Path)
static LONG | GetLocationType (const CString &in_strPath)
static bool | Is64BitOS ()
static bool | IsLinuxOS ()
static bool | IsWindowsOS ()
static bool | IsFileSystemCaseSensitive ()
static bool | IsScriptingLanguageInstalled (const CString &in_strLangOrFile)
static CString | Translate (const CValue &in_ToTranslate, const CString &in_dictionary, const CString &in_string1=CString(), const CString &in_string2=CString(), const CString &in_string3=CString())
static CString | Slash ()
static CString | BuildPath (const CString &in_segment1, const CString &in_segment2, const CString &in_segment3=CString(), const CString &in_segment4=CString(), const CString &in_segment5=CString(), const CString &in_segment6=CString(), const CString &in_segment7=CString(), const CString &in_segment8=CString())
static bool | EnsureFolderExists (const CString &in_Path, const bool in_bHasFileName)
static CString | ResolveTokenString (const CString &in_TokenString, const CTime &in_Time, bool in_bVerbose, const CStringArray &in_TokenNames=CStringArray(), const CStringArray &in_TokenValues=CStringArray())
static bool | IsAbsolutePath (const CString &in_strPath)

## Member Function Documentation

static CString ResolvePath | ( | const CString & | in_Path | ) | `[static]`

Resolves a path according to Linktab rules.

Parameters:

  in_Path | The path to be resolved.

Returns:
  The resolved path.

static LONG GetLocationType | ( | const CString & | in_strPath | ) | `[static]`

Determines whether a location is a workgroup, user, addon, factory, custom, or other type of location.

Parameters:

  in_strPath | A full path name of a file or directory. The location does not need to exist.

Returns:
  The siInstallationPath enum value that best describes the location.

static bool Is64BitOS | ( |  | ) | `[static]`

Returns true if Softimage is running on a 64-bit operating system.

Returns:
  True if Softimage is running on a 64-bit operating system, and False otherwise.

static bool IsLinuxOS | ( |  | ) | `[static]`

Returns true if Softimage is running on Linux.

Returns:
  True if Softimage is running on Linux, and False otherwise.

static bool IsWindowsOS | ( |  | ) | `[static]`

Returns true if Softimage is running on Microsoft Windows.

Returns:
  True if Softimage is running on Microsoft Windows, and False otherwise.

static bool IsFileSystemCaseSensitive | ( |  | ) | `[static]`

Returns true if Softimage is running on a case-sensitive file system. For example, the file system on Microsoft Windows is case-insensitive, so `Temp.txt` and `TEMP.TXT` are the same file. Linux, however, has a case-sensitive file system. This function is provided to help write code that works properly on both platforms.

Returns:
  True if the file system is case-sensitive, and False otherwise.

static bool IsScriptingLanguageInstalled | ( | const CString & | in_strLangOrFile | ) | `[static]`

Returns true if the specified scripting language is installed.

Parameters:

  in_strLangOrFile | The name of a scripting language or the name of a script file. Valid language names are `VBScript`, `JScript`, `Python`, and `PerlScript`. Valid script file names must have the extension .vbs (VBScript), .js (JScript), .pl (PerlScript), .py (Python), or .pys (Python).

Returns:
  True if the specified scripting language is installed, and False otherwise.

static CString Translate | ( | const CValue & | in_ToTranslate,
|  | const CString & | in_dictionary,
|  | const CString & | in_string1 = `CString()`,
|  | const CString & | in_string2 = `CString()`,
|  | const CString & | in_string3 = `CString()`
| ) |  | `[static]`

Returns the translation of a string from the specified Softimage translation dictionary. A translation dictionary is a table that maps English strings to another language.

Translation dictionaries are stored in .dict files. The translation dictionaries for a specific language are stored in .dict files in a subfolder of `Application/Dictionary` (in the Factory location). For example, the Japanese translation dictionaries are stored in the `Application/Dictionary/jp` folder.

Each string can be referenced by its numeric ID or by the English version of the string.

Some strings contain `"%s"` placeholders for string substitutions. For example, a message like "File c:\temp\myfile.txt not found" is stored in the dictionary as "File %s not found". The `"%s"` token is a placeholder for the file name. A string can contain up to three `s` placeholders.

When you call Translate, the optional arguments `in_string1`, `in_string2`, and `in_string3` specify the strings used to replace the placeholders. The number of optional strings supplied to Translate must match the number of placeholders. Other printf-type tokens, such as `d`, are not supported and may cause a crash.

Parameters:

  in_ToTranslate | The English string you want to translate. If the specified string is not found in the dictionary, or if the current language is English, you get back the same string you passed in.

You can also pass in the numeric ID (an unsigned int) of a string in the dictionary. If a string with that ID cannot be found, you get back an empty string.

Parameters:

  in_dictionary | The file name of the dictionary (without the .dict extension).
  in_string1 | Optional. The string to substitute for the first `s` in the dictionary string.
  in_string2 | Optional. The string to substitute for the second `s` in the dictionary string.
  in_string3 | Optional. The string to substitute for the third `s` in the dictionary string.

Returns:
  The translation of the specified English string into the current language.

Example:
  Demonstration of how to use the CUtils::Translate utility

              using namespace XSI;
              Application app;

              // You can't translate any arbitrary string, only
              // ones that are already in the dictionary.

              CString pixelRatio = CUtils::Translate( L"Pixel %s Ratio", L"XSIXSI", L"Pixel" ) ;
              app.LogMessage( L"Pixel Ratio translated is " + pixelRatio ) ;
              // Expected output: Pixel Ratio translated is Pixel Pixel Ratio

              // Load a Softimage warning message, in English
              // it says "Do you want to remove it?"

              CValue valNumber((LONG) 333);
              CString errorMsg = CUtils::Translate( valNumber, L"XSIMSGCAT" ) ;
              app.LogMessage( errorMsg ) ;
              // Expected output: Do you want to remove it?

              // This is an error message that contains additional
              // context information

              // Dictionary contains: "31$Path %s has been changed to %s"
              valNumber =  (LONG)32;
              CString warningMsg = CUtils::Translate((LONG)32, L"XSIMSGCAT", L"C:\\out.txt", L"C:\\temp\\out.txt" );
              app.LogMessage( warningMsg, siWarningMsg) ;

              // Expected output: 31$Path C:\out.txt has been changed to C:\temp\out.txt

static CString Slash | ( |  | ) | `[static]`

Returns the correct path-separator character for the current platform. For example, Slash returns a forward slash ("/") for Linux and a backslash ("\") for Windows. This is useful for writing cross-platform code.

Returns:
  A string with a single slash character.

static CString BuildPath | ( | const CString & | in_segment1,
|  | const CString & | in_segment2,
|  | const CString & | in_segment3 = `CString()`,
|  | const CString & | in_segment4 = `CString()`,
|  | const CString & | in_segment5 = `CString()`,
|  | const CString & | in_segment6 = `CString()`,
|  | const CString & | in_segment7 = `CString()`,
|  | const CString & | in_segment8 = `CString()`
| ) |  | `[static]`

Builds a full path by concatenating one or more path fragments. Path fragments include drive letters, server names (`"\\server"`), device names, folder names, file names, and special symbols such as `".."` and `"~"`.

Path fragments do not need to include a path separator character. BuildPath makes sure there is a single path separator character between each part of the path. For example, `BuildPath`( `"users"`, `"yanick"` ) returns `"users\yanick"` on Windows and `"users/yanick"` on Linux. The path does not need to specify an existing file or folder.

BuildPath makes it easier to write cross-platform code that deals with file and folder paths.

Parameters:

  in_segment1 | The first part of a path (for example, `"C:"` or `"/MyDisk"`).
  in_segment2 | The second part of the path.
  in_segment3 | An optional fragment to append to the path.
  in_segment4 | An optional fragment to append to the path.
  in_segment5 | An optional fragment to append to the path.
  in_segment6 | An optional fragment to append to the path.
  in_segment7 | An optional fragment to append to the path.
  in_segment8 | An optional fragment to append to the path.

Returns:
  A path composed from the specified fragments.

static bool EnsureFolderExists | ( | const CString & | in_Path,
|  | const bool | in_bHasFileName
| ) |  | `[static]`

Makes sure that all directories in the specified path exist. For example, if the specified path is `"c:\temp\a\b\c\out.txt"` and `a`, `b`, and `c` do not exist, then this function creates them.

If the path is invalid or the user does not have sufficient permissions to create the directory, this function returns False.

Parameters:

  in_Path | A full (absolute) path, which can be either a network or local path.
  in_bHasFileName | True if the path includes a file name. If False, EnsureFolderExists interprets any file name as a directory name.

Returns:
  True if successful and False otherwise.

static CString ResolveTokenString | ( | const CString & | in_TokenString,
|  | const CTime & | in_Time,
|  | bool | in_bVerbose,
|  | const CStringArray & | in_TokenNames = `CStringArray()`,
|  | const CStringArray & | in_TokenValues = `CStringArray()`
| ) |  | `[static]`

Resolves a token (a word surrounded by square brackets) string at a given time. There are two classes of tokens:

- Universal: [Project], [Scene], [Date], [Time], [Frame], [Field], [User], [Host], [Env], and [Value]
- Context-Specfic: For example, the [Pass] tokenm which is render-specific instead of universal

This call is only aware of the universal tokens. If any existing context-specific tokens are needed, they will need to be supplied as user-defined tokens.

To specify user-defined tokens, you can pass arrays representing token names and values in the `in_TokenNames` and `in_TokenValues` arguments which will be used to resolve the token string. The two arrays of CString values must have the same size.

See section "Tokens and Templates" in the Softimage User Guide for a list of all the built-in tokens.

Parameters:

  in_TokenString | The input string containing tokens.
  in_Time | The time used to resolve time dependent tokens.
  in_bVerbose | True to log error messages.
  in_TokenNames | An optional array of strings representing the user token names.
  in_TokenValues | An optional array of strings representing the user token values.

Returns:
  The resolved string. In case of failure an empty CString is returned.

Since:
  6.01

static bool IsAbsolutePath | ( | const CString & | in_strPath | ) | `[static]`

Returns true if the file path given is an absolute path. An absolute path is a path that can be resolved from the root of the file system. On the Windows platform, this means either a path that starts with a drive letter or a full UNC path. On Linux, it means a path that starts with a slash (`'/'`).

Note:
  It is not necessary for the path to exist before calling this function.

Parameters:

  in_strPath | The path to test for absoluteness.

Returns:
  true if the path is absolute.

Since:
  7.0

The documentation for this class was generated from the following file:

- xsi_utils.h