Page 1 of 1
Flag for OpenFile: #PB_File_NonExclusive
Posted: Sat Feb 27, 2010 6:55 pm
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 ] )
Re: Flag for OpenFile: #PB_File_NonExclusive
Posted: Sun Feb 28, 2010 12:01 pm
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.
Re: Flag for OpenFile: #PB_File_NonExclusive
Posted: Sun Feb 28, 2010 12:07 pm
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.
Re: Flag for OpenFile: #PB_File_NonExclusive
Posted: Sun Feb 28, 2010 7:01 pm
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.
Re: Flag for OpenFile: #PB_File_NonExclusive
Posted: Sun Feb 28, 2010 10:50 pm
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.
Re: Flag for OpenFile: #PB_File_NonExclusive
Posted: Tue Mar 02, 2010 12:12 am
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().