Changeset 8219


Ignore:
Timestamp:
Jan 18, 2008, 6:24:17 PM (12 years ago)
Author:
gb
Message:

%CREATE-FILE handles :IF-EXISTS NIL by setting #$O_EXCL in open call,
recognizing #$EEXIST error return and returning NIL if file exists.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/level-1/l1-files.lisp

    r7796 r8219  
    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 existed
     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.