[physfs] Sharing Modes on Windows

Christoph Nelles evilazrael at evilazrael.de
Mon Mar 15 19:41:22 EDT 2010


Hi,

i am trying to open a file in read-write mode via PHYSFS. This means
opening the files twice, once for reading, once for writing. Badly this
causes a sharing violation telling me the (or another) process is using
the file. This comes from the open & sharing mode combinations in the
doOpen function on the windows platform.
openRead will do GENERIC_READ, FILE_SHARE_READ while openWrite will do
GENERIC_WRITE, FILE_SHARE_READ. According to the table on
http://msdn.microsoft.com/en-us/library/aa363874(VS.85).aspx this will
allow a file to be opened multiple times for reading (as the archivers
do) resp. the file will be opened for writing while another read opening
is allowed, but this time the sharing mode must be set to
FILE_SHARE_WRITE. But sorrowly the sharing mode is fixed to
FILE_SHARE_READ.

Is there any reason this was done this way? On the posix platform there
is no such limit (haven't tested, only saw no flock() ;)). I propose
setting the sharing mode to FILE_SHARE_READ | FILE_SHARE_WRITE, this
allows to open the same file many times simultaneously without any
limitation or the need to set the sharing mode apropiately.

Btw.: My ISO9660 archiver works on 32bit BE PowerPC, too. ;)


Regards

Christoph
-- 
Christoph Nelles

E-Mail    : evilazrael at evilazrael.de
Jabber    : eazrael at evilazrael.net      ICQ       : 78819723

PGP-Key   : ID 0x424FB55B on subkeys.pgp.net
            or http://evilazrael.net/pgp.txt



More information about the physfs mailing list