[Ecls-list] open :supersede and rename-file advise

Mark Hoemmen mhoemmen at cs.berkeley.edu
Mon Nov 26 17:01:48 UTC 2007


On 11/26/07, Geo Carncross <geocar at gmail.com> wrote:
> It's important to put tempfile in the same directory because otherwise
> it doesn't work. rename() (or MoveFileEx) is only atomic when it's
> changing the *name* of a file, and cannot move a file from one
> filesystem to another (i.e. across mount points where stat.st_dev
> changes). Additionally, (at least on unix) you cannot have permission
> to rename a file into a directory, but simultaneously not have
> permission to create a file in the same directory.

Ah, good point ;-)

> Maybe having a non-standard :temporary-pathname key (which defaulted
> to the pathname, with :name and/or :type chosen randomly) would be the
> right thing to do.
>
> The temporary file, however, shouldn't "look" like a regular file-
> give it a name like (format nil "temp,~a.~a.tmp" (get-universal-time)
> (incf *some-process-counter*)) so that a cleaner can be written easily
> (if anyone ever wants to).

POSIX has safer functions to handle this sort of thing.  I've got some
CFFI + Lisp glue to invoke them, if you're interested.  I've used it
in my Lisp initialization script before:  a hackish way to figure out
the file extension for FASLs is to compile a temporary file.

Should we take this discussion off-list and do some hacking?

mfh




More information about the ecl-devel mailing list