FunctionPackage: exclToCDocOverviewCGDocRelNotesIndexPermutedIndex
Allegro CL version 6.2
This page is new in 6.2

rename-file-raw

Arguments: filespec new-name

The function is similar to cl:rename-file in that it renames the file or directory specified by the filespec to the file or directory specified by the new-name argument.

rename-file-raw differs from cl:rename-file in that it mimics the UNIX mv/Windows MOVE method of resolving relative pathnames when renaming files. If new-name is a relative pathname, it is merged with *default-pathname-defaults* to get the actual new name. cl:rename-file merges new-name with filespec. The difference can be seen with the following example:

;; *default-pathname-defaults* is an absolute pathname and
;; both directories /usr/home/user1/tmp/ and 
;; /usr/home/user1/tmp/tmp/ exist.
*default-pathname-defaults*
  -> #p"/usr/home/user1/"

(probe-file "tmp/foo.cl") -> #p"/usr/home/user1/tmp/foo.cl"
(probe-file "tmp/tmp/") -> #p"/usr/home/user1/tmp/tmp/"

;;  Only one of the following four forms may be evaluated, 
;;  since after evaluation the file specified by 
;;  the first argument will not exist.
;;  Only the first value returned is shown.

(rename-file "tmp/foo.cl" "tmp/baz.cl")
  -> #p"/usr/home/user1/tmp/tmp/baz.cl"
(rename-file-raw "tmp/foo.cl" "tmp/baz.cl")
  -> #p"/usr/home/user1/tmp/baz.cl"

(rename-file "tmp/foo.cl" "baz.cl")
  -> #p"/usr/home/user1/tmp/baz.cl"
(rename-file-raw "tmp/foo.cl" "baz.cl")
  -> #p"/usr/home/user1/baz.cl"

Like cl:rename-file, rename-file-raw returns three values: The new name, the truename of filespec, and the truename of the new name. Here is the source, followed by the source of cl:rename-file:

(defun rename-file-raw (filespec new-name)
  (let ((new-name (pathname new-name))
	(old-truename (truename filespec)))
    (excl::filesys-rename-file (namestring old-truename)
			 (namestring
			  (merge-pathnames
			   (translate-logical-pathname new-name))))
    (values new-name old-truename (truename new-name))))

(defun rename-file (filespec new-name)
  (let ((defaulted-new-name (merge-pathnames new-name filespec))
	(old-truename (truename filespec)))
    (excl::filesys-rename-file (namestring old-truename)
			 (namestring (translate-logical-pathname
				      (pathname defaulted-new-name))))
    (values defaulted-new-name old-truename
	    (truename defaulted-new-name))))

The situation in release 6.1 was confused, because the behavior of cl:rename-file depended on the value of *default-pathname-defaults* in inappropriate ways (when *default-pathname-defaults* was an absolute pathname, 6.1 cl:rename-file worked like the new rename-file-raw; when *default-pathname-defaults* was an empty pathname -- #p"", 6.1 cl:rename-file worked as specified by ANSI, that is, as cl:rename-file works in 6.2. An additional function, rename-file-acl6.1 is provided which is the Allegro CL 6.1 implementation of cl:rename-file. Users who want the exact 6.1 behavior in 6.2 can use it. See cl:rename-file and excl:rename-file-raw in release-notes.htm for a complete discussion of this issue.


Copyright (c) 1998-2002, Franz Inc. Oakland, CA., USA. All rights reserved.
Documentation for Allegro CL version 6.2. This page is new in the 6.2 release.
Created 2002.2.26.

ToCDocOverviewCGDocRelNotesIndexPermutedIndex
Allegro CL version 6.2
This page is new in 6.2