Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

renameFile

renameFile( 
S_old 
S_new 
) 
=> t / nil 

Description:

The renameFile() function changes the name of a file or directory.The S_old argument points to the pathname of the file or directory to be renamed. The S_new argument points to the new pathname of the file or directory. If the SKILL path is nil, renameFile() would search the current directory. Otherwise, the SKILL path would be searched first for S_old. A path that is anchored to the current directory, for example, ./, ../, or ../../.., and so on, is not considered as a relative path.

Arguments:

S_old

Points to the pathname of the file or directory to be renamed.

S_new

Points to the new pathname of the file or directory.

Value Returned

t

File or directory is successfully re-named.

nil

If S_old path does not exist.

If you do not have sufficient privileges to rename a file or directory, the renameFile() function throws an error (neither returns t nor nil). You can use the errset() function to handle such exceptional situations. For more information on the errset() function, see The errset Function in the Cadence SKILL Language User Guide.

Example

renameFile( "/usr/oldname" "/usr/newName" ) 
=> t
renameFile( "/usr/old" "/usr/new" ) 
=> nil ;if old does not exist.
renameFile( "old" "new" ) ;if old is a file while new is a directory
*Error* renameFile: is a directory
renameFile( "/usr/old" "/usr/new" ) ; if you do not have permissions to rename old
*Error* renameFile: permission denied

Related Topics

Input Output Functions


Return to top
 ⠀
X