[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions about OPEN



    Date: 5 Oct 84 13:09:40 EDT
    From: Charles Hedrick <HEDRICK@RUTGERS.ARPA>

    On the DEC-20 it would certainly be better to maintain the distinction
    between filename and stream.  A common strategy for an editor is to
    write a new copy of a file with a temporary file name, close it, and
    then rename it on top of the original.  This minimizes the probability
    of damage in a crash.  One would prefer to use the same JFN for this
    entire process.  A JFN is a small integer that is a handle on a file.
    If you keep the JFN active, you are sure that nobody else is going to
    rename the file out from under you or do anything else nefarious.
    This is easy if all of the operations can be done on streams.  My
    feeling is that the distinction makes sense on some OS's, and on 
    others causes no harm (other than extra code), so it should be kept.
    -------

I think the point here is that you don't write such an editor in Common Lisp by
generating a temporary file name yourself (how do you make the file name syntax
for such temporary files portable across implementations with different maximum
file name lengths and different legal characters to appear in file names?),
calling OPEN, calling CLOSE, and calling RENAME-FILE.  Instead, you call
OPEN in :IF-EXISTS :SUPERSEDE mode, and the implementation takes care of doing
whatever combination of OPEN's, CLOSE's, and RENAME's is appropriate for the
particular file system.  Your editor might want to check
  (eq (pathname-version pathname) ':newest),
which is an implementation-independent operation, before deciding whether
to use supersede mode.  In Unix, where there are no version numbers, that
EQ test will always be false, you will always use supersede mode, and everything
will be fine.