// =========================================================================== // 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. // =========================================================================== global proc string pv_basename(string $fileName) // // Description: // Given a file name, return the basename. // { string $fName = $fileName; if (`about -nt`) { $fName = convert($fName); } string $buffer[]; int $nTokens; $nTokens = `tokenize $fName "/" $buffer`; if ($nTokens > 0) { $fName = $buffer[$nTokens-1]; } $nTokens = `tokenize $fName "." $buffer`; // baseName's can have a "." in them too. So // make sure we concatenate everything but the // last token, which will be the extension. // int $i = 0; $fName = ""; for( $i = 0; $i < ($nTokens-1); $i++) { if( $i > 0 ) { $fName += "."; } $fName = $fName + $buffer[$i]; } return $fName; }