Ns rename

From AOLserver Wiki
Jump to navigation Jump to search

Man page: http://aolserver.com/docs/tcl/ns_rename.html


NAME

ns_rename - Rename a file

SYNOPSIS

ns_rename file1 file2

DESCRIPTION

This command renames the file or directory file1 to the file or directory file2. Make sure that file1 exists the directories in which file1 and file2 reside exist, and that they are read/write accessible to the user that is running the AOLserver process. Caution: ns_rename will silently overwrite file2 if it is a file that already exists.
This is a legacy command from when Tcl did not have this functionality. It is now recommended you use Tcl's file rename command instead (subject to certain conditions - see under NOTES). In other words, this:
   ns_rename $file1 $file2
is equivalent to:
   file rename -force -- $file1 $file2

EXAMPLES

   # create an empty file called /tmp/ns_rename
   close open /tmp/ns_rename w
   # rename it to /tmp/ns_renamed
   ns_rename /tmp/ns_rename /tmp/ns_renamed
   # check to see if /tmp/ns_renamed exists
   % file exists /tmp/ns_renamed
   1

NOTES

Under Windows, Tcl 8.4 file rename does not preserve NTFS attributes such as compression state and security descriptor. Instead the file will inherit them from the destination directory. This is incorrect behavior (attributes should be retained when a file is renamed or moved within the same volume). ns_rename does not have this problem. In Tcl 8.5, this problem is also fixed, so it's safe to use file rename instead of ns_rename in Tcl 8.5 on all platforms.
Note that both ns_rename and file rename (all versions) suffer from the same issue - if file1 and file2 are the same, the file will get DELETED! On Windows this also happens if file1 and file2 differ only by case.

SEE ALSO

ns_chmod, ns_link, ns_mkdir, ns_rmdir, ns_symlink

Category Documentation - Category Core Tcl API