Changeset 8620


Ignore:
Timestamp:
Feb 29, 2008, 4:07:24 AM (12 years ago)
Author:
gb
Message:

%CREATE-FILE: use #$O_EXCL when possible, to better support more
:IF-EXISTS cases.

File:
1 edited

Legend:

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

    r7494 r8620  
    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              (eq if-exists :error)
     198              (not (probe-file path))) ()
    196199          "~s ~s not implemented yet" :if-exists if-exists)
    197200  (let* ((unix-name (native-translated-namestring path))
    198          (fd (fd-open unix-name (logior #$O_WRONLY #$O_CREAT #$O_TRUNC))))
     201         (fd (fd-open unix-name (logior #$O_WRONLY #$O_CREAT #$O_TRUNC
     202                                        (if (or (null if-exists)
     203                                                (eq if-exists :error))
     204                                          #$O_EXCL
     205                                          0)))))
    199206    (if (< fd 0)
    200       (signal-file-error fd path)
     207      (if (and (null if-exists)
     208               (eql fd (- #$EEXIST)))
     209        (return-from %create-file nil)
     210        (signal-file-error fd path))
    201211      (fd-close fd))
    202212    (%realpath unix-name)))
Note: See TracChangeset for help on using the changeset viewer.