// =========================================================================== // 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. // =========================================================================== // // // Creation Date: 2012 // // Description: // This script consolidates // - fluidCacheGetCurrentDir() in performCreateFluidCache.mel // - geomCacheGetCurrentDir() in performCreateGeometryCache.mel // - cacheGetCurrentDir() in performCreateNclothCache.mel // into cacheGetCurrentDir () // // Hardcoded "data" is now `workspace -q -fre $filerule` where $filerule is the corresponding file rule // for the particular cache type. // global proc string cacheGetCurrentDir(string $filerule, string $optionVarName, string $gCacheCurrentProject, int $import ) // // Return a string corresponding to the current directory preference. // Use the current project's data directory by default. // { // first find the current project directory, if it is defined // int $needSubdir = 1; // find the directory for the requested file rule, if it exists, or use the current proj string $currentRule = (`workspace -q -fre $filerule`); // if the fileRule is null, this will return the current project // if it's relative, this will expand to include the project path, if its already absolute, it stays absolute. string $cacheDir = `workspace -en $currentRule`; $cacheDir += "/"; // check what the user has as their preference // if (`optionVar -exists $optionVarName`) { string $cacheVar = `optionVar -q $optionVarName`; if ($cacheVar != $gCacheCurrentProject) { $cacheDir = $cacheVar; $needSubdir = 0; } } if( $needSubdir ) { // Find default subdirectory location // string $subDir = getNameForCacheSubDir( 0, $cacheDir, "" ); string $cacheDirTmp = $cacheDir + $subDir; if ( !$import || `file -q -ex $cacheDirTmp`) { $cacheDir = $cacheDirTmp; } } return $cacheDir; }