File Access (Locking / Sharing)

Just starting out? Need help? Post your questions and find answers here.
Lemming
New User
New User
Posts: 3
Joined: Sat Mar 06, 2004 8:13 pm

File Access (Locking / Sharing)

Post 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
Lemming
New User
New User
Posts: 3
Joined: Sat Mar 06, 2004 8:13 pm

Found a workaround

Post 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
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hiya Lemming, welcome aboard.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: Found a workaround

Post 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 :)
SPAMINATOR NR.1
Fred
Administrator
Administrator
Posts: 18237
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Rings: :lol:
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post 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..)

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post 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)?
SPAMINATOR NR.1
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post 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?!?

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
User avatar
einander
Enthusiast
Enthusiast
Posts: 744
Joined: Thu Jun 26, 2003 2:09 am
Location: Spain (Galicia)

Post 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
Post Reply