This is a code snippet for such a function with Windows and Unix. Even here the dreaded NFS raises its ugly head. The Windows code has worked fine, but Windows gurus might find some way to improve it.

  /*Open the file if possible in the appropriate mode.*/
#if IS_WIN32
  mode = GENERIC_READ;
  if (!read_only) mode = mode | GENERIC_WRITE;
  if (exclusive) mode_share = 0;
  else {
    mode_share = FILE_SHARE_READ;
    if (!read_only) mode_share = mode_share | FILE_SHARE_WRITE;
  }   /*if/else*/

  if (autocreate) mode_create = CREATE_ALWAYS;
  else mode_create = OPEN_EXISTING;

  fd = CreateFile(filename, mode, mode_share, NULL, mode_create,
                  FILE_ATTRIBUTE_NORMAL, NULL);
  if (fd == INVALID_HANDLE_VALUE) {
    errormet = TRUE; errorflag = IO; errorsub = 'M';
    return(TRUE);
  }  /*if*/
#else
  if (read_only) mode = O_RDONLY;
  else mode = O_RDWR;
#if IS_CYGWIN
  mode = mode | O_BINARY;
#endif

  /*Set the mode for exclusive open.*/
#if IS_AIX
  if (exclusive) mode = mode | O_NSHARE;   /*!!!!!! Not supported by NFS.*/
#else
  if (exclusive) mode = mode | O_EXCL;
#endif

  /*We may have a PREPARE of an existing file.  Save time by opening
  with truncate.*/
  if (autocreate) mode = mode | O_TRUNC | O_CREAT;

  fd = open(filename, mode, 0666);

  /*A handle value of less then zero indicates that the file was
  neither opened nor created.*/
  if (fd < 0) {
    errormet = TRUE; errorflag = IO; errorsub = 'M';
    return(TRUE);
  }  /*if*/
#endif

[EMAIL PROTECTED] wrote:
Joe Wilson <[EMAIL PROTECTED]> wrote:

--- [EMAIL PROTECTED] wrote:

Is there something that the SQLite core can do better?

Perhaps exclusive locks on journal files would help avoid this problem.
Or are the -journal and etilqs_* files supposed to be sharable by other sqlite processes?



They are, at least on unix.  On unix, both files are opened with
the O_EXCL flag.  How do I do the same thing for windows?
--
D. Richard Hipp  <[EMAIL PROTECTED]>


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------



-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to