Flag for OpenFile: #PB_File_NonExclusive

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Flag for OpenFile: #PB_File_NonExclusive

Post by Kaeru Gaman »

would be nice to have a flag for OpenFile to open files with nonexclusive write access.
this would enable us to write our own multi-access database systems.

http://www.purebasic.fr/english/viewtop ... 13&t=41273

#PB_File_NonExclusive = -1
#PB_File_Exclusive = 0

OpenFile(#File, FileName$ [, AccessFlag = #PB_File_Exclusive ] )
oh... and have a nice day.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Flag for OpenFile: #PB_File_NonExclusive

Post by Mistrel »

Doesn't write access require exclusive access? ReadFile won't lock it, I think. It's only when you want to open a file for writing more than once that it locks.

I haven't tried it so I'm talking off the top of my head. But this is how I think it works.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Re: Flag for OpenFile: #PB_File_NonExclusive

Post by Kaeru Gaman »

this is correct, that's how it is now.
I don't know if it is even possible to grant multiple write access.
but if it was possible, I wish we could use it.
if the OS would not allow it, this request is pointless and can be closed.
oh... and have a nice day.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Flag for OpenFile: #PB_File_NonExclusive

Post by Trond »

I use this all the time with my web browser when downloading mp3 files. I open them in Winamp before they are completely downloaded. So this is definetely possible.
Also this is one of the reasons I really HATE Firefox, it gives downloaded files a different file extension until they are completely downloaded, when it renames them. Of course this makes it inconvenient to open them in the correct program in the first place, and when the download is completed you have to open them again.
UserOfPure
Enthusiast
Enthusiast
Posts: 469
Joined: Sun Mar 16, 2008 9:18 am

Re: Flag for OpenFile: #PB_File_NonExclusive

Post by UserOfPure »

Trond wrote:it gives downloaded files a different file extension until they are completely downloaded
That's a safety feature. If you open an incomplete file, it can cause buffer overflows and other problems. I recall seeing that as an Internet Explorer exploit, which is just another reason why FF is safer than IE.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Flag for OpenFile: #PB_File_NonExclusive

Post by blueznl »

Kaeru Gaman wrote:this is correct, that's how it is now.
I don't know if it is even possible to grant multiple write access.
but if it was possible, I wish we could use it.
if the OS would not allow it, this request is pointless and can be closed.
It is possible under Windows, no problem. Just not with PureBasic's OpenFile().
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply