Ignore:
Timestamp:
Jan 23, 2008, 5:50:07 AM (12 years ago)
Author:
gb
Message:

Handle and use (%CREATE-FILE ... :IF-EXISTS NIL).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-1/l1-files.lisp

    r7796 r8237  
    193193  (when (directory-pathname-p path)
    194194    (return-from %create-file (probe-file-x path)))
    195   (assert (or (eql if-exists :overwrite) (not (probe-file path))) ()
     195  (assert (or (eql if-exists :overwrite)
     196              (null if-exists)
     197              (not (probe-file path))) ()
    196198          "~s ~s not implemented yet" :if-exists if-exists)
    197199  (let* ((unix-name (native-translated-namestring path))
    198          (fd (fd-open unix-name (logior #$O_WRONLY #$O_CREAT #$O_TRUNC))))
     200         (fd (fd-open unix-name (logior #$O_WRONLY #$O_CREAT #$O_TRUNC
     201                                        (if (null if-exists)
     202                                          #$O_EXCL
     203                                          0)))))
    199204    (if (< fd 0)
    200       (signal-file-error fd path)
     205      (if (eql fd (- #$EEXIST))         ; #$O_EXCL was set and file exists
     206        (return-from %create-file nil)
     207        (signal-file-error fd path))
    201208      (fd-close fd))
    202209    (%realpath unix-name)))
Note: See TracChangeset for help on using the changeset viewer.