Subject: Re: File renaming misery
From: rpw3@rpw3.org (Rob Warnock)
Date: Fri, 12 May 2006 01:56:17 -0500
Newsgroups: comp.lang.lisp
Message-ID: <0eGdnUrCnaIMrPnZRVn-og@speakeasy.net>
Steven E. Harris <seh@panix.com> wrote:
+---------------
| Mark Wooding <mdw@distorted.org.uk> writes:
| > Is there a sensible way of doing what I want, in Common Lisp?  
| 
| I got the following to work in LispWorks, more through experimentation
| than understanding:
| > (rename-file (make-pathname :directory '(:absolute "temp")
|                               :name "foo" :type "new")
|                (make-pathname :type :unspecific))
| #P"C:/temp/foo"
| #P"C:/temp/foo.new"
| #P"C:/temp/foo"
+---------------

It also works in CMUCL [on Linux or FreeBSD, at least]:

    cmu> (rename-file "foo.new"
		      (make-pathname :name "foo" :type :unspecific))

    #p"/usr/u/rpw3/foo"
    #p"/usr/u/rpw3/foo.new"
    #p"/usr/u/rpw3/foo"
    cmu> 

But as you saw, I'm sure, Pascal B. warned that this use
of :UNSPECIFIC is non-portable. However, CLHS 19.2.2.2.3
*does* say:

    19.2.2.2.3 :UNSPECIFIC as a Component Value
    ....
    However, a conforming program can, if it is careful, successfully
    manipulate user-supplied data which contains or refers to non-portable
    pathname components.
    ...
    When writing the value of any pathname component, the consequences
    are undefined if :unspecific is given for a pathname in a file system
    for which it does not make sense.

But in a file system for which it *DOES* make sense...  ;-}  ;-}


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607