Best Practices and Technology in Software Delivery
13 Oct
Note that the Perl rename function is actually an implementation of the UNIX rename C system call. This call does what you would normally associate with the UNIX ‘mv’ command or DOS ‘move’ and ‘rename’ commands. That is you can “rename” a file in Perl to a new directory location, not just rename the file in place. I learned this recently working on a deployment script for JBoss.
I had earlier implemented the archive extraction by using the ‘move’ function from the File::Copy package. This function actually does a very careful recursive copy, preserving permissions, and then deleting the original at the end. This makes it very slow compared to the ‘rename’ function which just alters the directory entry and does not actually copy any data from one section on disk to another.
With this function, a new directory entry is created for the target file that points to the areas on disk of the original file data. After this is complete, the source directory entry is deleted without affecting the data chunks of the original. This is a much faster operation than copying each data area to create a second complete copy.
Leave a reply
You must be logged in to post a comment.