On 6/21/06, Ran <[EMAIL PROTECTED]> wrote:
Thanks for your reply. I know that I should lock the file before copying it,
and the "BEGIN IMMEDIATE" is indeed a nice trick.
However, I think I didn't explain my problem clearly. I would like to copy
that file _without_ using the sqlite library (so using the windows API
only).

I do the same with my code.
I do a file copy once the lock is established.


When I try to do that with:
CreateFile(db_file,
                GENERIC_READ,
                0,
                NULL,
                OPEN_EXISTING,
                FILE_ATTRIBUTE_NORMAL, NULL);

I get error 0x20 - "the process cannot access the file becuase it is beging
used by other process".

If you don't have an exclusive lock in Sqlite you should be able to
get a read only copy through the file system. That's how I do it.



I have two processes - one is linked with sqlite, and the other (which does
the copying) is not. I can lock using the first process, but I need to make
the copy with the other, and without linking to sqlite (although sqlite is
small, I find it a pity to link to it _only_ in order to do such a copy).

You'll need to have some communication between your processes
so one knows that the other has locked the file and the copy can
proceed. I wrote my replication program to be run from cron.
It waits for a time trying to establish the correct lock, you might
try the 'delay and retry' method.

Reply via email to