🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages Started by Goran Ekstrom Sun, 18 Feb 2007 21:49
File access syncronization
#2448
Author: Goran Ekstrom
Date: Sun, 18 Feb 2007 21:49
16 lines
1580 bytes
Hi,
need to synch file access to a file created by another app. The idea here is
to use mutually exclusive file locking where the creator opens/creates,
writes and closes and the reader waits for access and then opens
exclusively. When the reader is ready, the file should be removed and the
writer then recreates the file next time.

It is this Open-then-delete part in the reader app. that I am wondering
about. How can I open, close, delete without any access time gaps here? One
idea is to rename the file, assuming the rename function is lock aware but
there is only a STDIO function called "rename" available as i seems. Will
this function do or do you have any other ideas?

Thanks
Goran Ekstrom
Close Talk Marketing
Re: File access syncronization
#2449
Author: Bob Gonder
Date: Mon, 19 Feb 2007 03:15
17 lines
1702 bytes
Goran Ekstrom wrote:

>It is this Open-then-delete part in the reader app. that I am wondering
>about. How can I open, close, delete without any access time gaps here? One
>idea is to rename the file, assuming the rename function is lock aware but
>there is only a STDIO function called "rename" available as i seems. Will
>this function do or do you have any other ideas?

Sure.
If rename fails, then either the file doesn't exist (you can check
that) or it is locked.
If rename doesn't fail, then you can open it with it's new name.

This has the advantage that the writter can start writing right away.

You can also use CreateFile() with the FILE_FLAG_DELETE_ON_CLOSE
option to read and delete the file.
Re: File access syncronization
#2457
Author: Goran Ekstrom
Date: Mon, 19 Feb 2007 18:24
7 lines
1063 bytes
> You can also use CreateFile() with the FILE_FLAG_DELETE_ON_CLOSE
> option to read and delete the file.

Perfect, thanks!

Goran 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads