Page 1 of 1

File Access (Locking / Sharing)

Posted: Sat Mar 06, 2004 8:25 pm
by Lemming
Hi there,
is there a way to open a file for input that is already opened for output by another task?
What I'm looking for is an equivalent to
OPEN "BLA" FOR INPUT LOCK SHARED AS #1
as can be used in other Basic dialects... :?:

Thanks already

Found a workaround

Posted: Sat Mar 06, 2004 10:01 pm
by Lemming
Well,
I've found myself a workaround... :idea:
The Fastfile library does the trick, it just opens the file and doesn't care about it being opened for write. Great! :D

Posted: Sat Mar 06, 2004 10:43 pm
by Dare2
Hiya Lemming, welcome aboard.

Re: Found a workaround

Posted: Sun Mar 07, 2004 8:17 pm
by Rings
Lemming wrote:Well,
I've found myself a workaround... :idea:
The Fastfile library does the trick, it just opens the file and doesn't care about it being opened for write. Great! :D
i have studied the api for all the flags while using CreateFile...... hint to fred :)

Posted: Mon Mar 08, 2004 11:29 am
by Fred
Rings: :lol:

Posted: Mon Mar 08, 2004 11:38 am
by LarsG
just a quick question:
does FastFile give you any way of knowing that the file is in use?! (ie. not just open it, locked or not..)

Posted: Tue Mar 09, 2004 11:30 am
by Rings
LarsG wrote:just a quick question:
does FastFile give you any way of knowing that the file is in use?! (ie. not just open it, locked or not..)
yes in one way of course
Should i make a Command like IsLocked(Filename)?

Posted: Tue Mar 09, 2004 3:03 pm
by LarsG
I've never had any problems working with this myself, but I guess it would be crucial to check if the file is being worked on by another program at the moment you're trying to use it.. what do you think?!?

Posted: Wed Mar 10, 2004 10:26 am
by einander
@Lemming:
May be this helps:
From WinApi documentation, WriteFileEx_() function:
Applications must not read from nor write to the input buffer that a read operation is using until the read operation completes. A premature access to the input buffer may lead to corruption of the data read into that buffer.
You can try the SleepEx_() API function to enter an alertable wait state.

Best regards
Einander