mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Fix opening of read-only files on Windows
The CreateFile* functions return INVALID_HANDLE_VALUE on error, not NULL. http://article.gmane.org/gmane.comp.kde.devel.taglib/2346
This commit is contained in:
parent
c6f7ad3e83
commit
ade8dc1a21
@ -56,10 +56,16 @@ namespace {
|
||||
{
|
||||
DWORD access = readOnly ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE);
|
||||
|
||||
HANDLE handle;
|
||||
if(wcslen(path) > 0)
|
||||
return CreateFileW(path, access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
handle = CreateFileW(path, access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
else
|
||||
return CreateFileA(path, access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
handle = CreateFileA(path, access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
|
||||
if(handle == INVALID_HANDLE_VALUE)
|
||||
handle = NULL;
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
size_t fread(void *ptr, size_t size, size_t nmemb, HANDLE stream)
|
||||
|
Loading…
Reference in New Issue
Block a user