// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // Procedure Name: // getFileRuleDirectory // // Description: // This script returns the full directory path of the location // set for the given file rule. If multiple existing paths are // set, the first one is used. If none of the paths exist, the // first one is created. // // Input Arguments: // string $fileRule: the file rule to get the location path for // // Returns: // string: the full directory location path // global proc string getFileRuleDirectory(string $fileRule) { string $subdir = `workspace -fre $fileRule`; string $buffer[]; int $numTokens = `tokenize $subdir ";" $buffer`; int $i; string $dir = ""; int $foundExistingDir = 0; for($i = 0; $i < $numTokens; $i++) { string $nextDir = `workspace -expandName $buffer[$i]`; $foundExistingDir = `filetest -d $nextDir`; if($i == 0 || $foundExistingDir) { $dir = $nextDir; if($foundExistingDir) { break; } } } if(!$foundExistingDir) { sysFile -makeDir $dir; } return $dir; }