Changeset 10639


Ignore:
Timestamp:
Sep 8, 2008, 6:04:23 AM (11 years ago)
Author:
gb
Message:

Sharing issues when opening .cdb files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lib/db-io.lisp

    r10519 r10639  
    9292  ;;; Open the file specified by PATHNAME for input and return a
    9393  ;;; file id.
     94  #-windows-target
    9495  (defun fid-open-input (pathname)
    9596    (let* ((id (fd-open (cdb-native-namestring pathname) #$O_RDONLY)))
     
    9798        (%errno-disp id pathname)
    9899        id)))
     100  ;; On Windows, open() can't open the same file twice, which breaks
     101  ;; bootstrapping.  Use CreateFile instead, and tell it to share.
     102  #+windows-target
     103  (defun fid-open-input (pathname)
     104    (with-filename-cstrs ((name (cdb-native-namestring pathname)))
     105      (let* ((handle (%ptr-to-int (#_CreateFileW
     106                                   name
     107                                   #$GENERIC_READ
     108                                   #$FILE_SHARE_READ
     109                                   (%null-ptr)
     110                                   #$OPEN_EXISTING
     111                                   #$FILE_ATTRIBUTE_NORMAL
     112                                   (%null-ptr)))))
     113        (if (eq handle #xffffffffffffffff)
     114          (error "Error opening CDB database ~S" pathname)
     115          (#__open_osfhandle handle #$O_RDONLY)))))
     116 
    99117 
    100118  ;;; Read N octets from FID into BUF.  Return #of octets read or error.
Note: See TracChangeset for help on using the changeset viewer.