domoticz / minizip

Minizip. Portable zip & unzip lib
10 stars 5 forks source link

Less restrictive sharing mode for minizip. #3

Open IEUser999 opened 8 months ago

IEUser999 commented 8 months ago

Can the code be less restrictive with the sharing mode when it extracting archives? Why does it need exclusive read access if it is just extracting archives and not writing it?

Can below change be considered as improvement? Existing: lpdwShareMode = FILE_SHARE_READ; Proposed: lpdwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;

Function affected: win32_translate_open_mode

static void win32_translate_open_mode(int mode, DWORD* lpdwDesiredAccess, DWORD* lpdwCreationDisposition, DWORD* lpdwShareMode, DWORD* lpdwFlagsAndAttributes)
{
    *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;

    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER) == ZLIB_FILEFUNC_MODE_READ)
    {
        *lpdwDesiredAccess       = GENERIC_READ;
        *lpdwCreationDisposition = OPEN_EXISTING;
        *lpdwShareMode           = FILE_SHARE_READ;
    }
    else if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
    {
        *lpdwDesiredAccess       = GENERIC_WRITE | GENERIC_READ;
        *lpdwCreationDisposition = OPEN_EXISTING;
    }
    else if (mode & ZLIB_FILEFUNC_MODE_CREATE)
    {
        *lpdwDesiredAccess       = GENERIC_WRITE | GENERIC_READ;
        *lpdwCreationDisposition = CREATE_ALWAYS;
    }
}
gizmocuz commented 7 months ago

What issue are you facing? I can only assume if you only need read access it does not make a point to specify shared writing? Where do you experience a issue?