mscms: Fix OpenColorProfile to handle relative file names.
This commit is contained in:
parent
7c527199b6
commit
7200072622
|
@ -1,6 +1,6 @@
|
||||||
MODULE = mscms.dll
|
MODULE = mscms.dll
|
||||||
IMPORTLIB = mscms
|
IMPORTLIB = mscms
|
||||||
IMPORTS = advapi32
|
IMPORTS = shlwapi advapi32
|
||||||
EXTRALIBS = @LCMSLIBS@
|
EXTRALIBS = @LCMSLIBS@
|
||||||
|
|
||||||
C_SRCS = \
|
C_SRCS = \
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "wingdi.h"
|
#include "wingdi.h"
|
||||||
#include "winuser.h"
|
#include "winuser.h"
|
||||||
#include "winreg.h"
|
#include "winreg.h"
|
||||||
|
#include "shlwapi.h"
|
||||||
#include "icm.h"
|
#include "icm.h"
|
||||||
|
|
||||||
#include "mscms_priv.h"
|
#include "mscms_priv.h"
|
||||||
|
@ -1470,7 +1471,25 @@ HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing
|
||||||
if (!flags) return NULL;
|
if (!flags) return NULL;
|
||||||
if (!sharing) sharing = FILE_SHARE_READ;
|
if (!sharing) sharing = FILE_SHARE_READ;
|
||||||
|
|
||||||
|
if (!PathIsRelativeW( profile->pProfileData ))
|
||||||
handle = CreateFileW( profile->pProfileData, flags, sharing, NULL, creation, 0, NULL );
|
handle = CreateFileW( profile->pProfileData, flags, sharing, NULL, creation, 0, NULL );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DWORD size;
|
||||||
|
WCHAR *path;
|
||||||
|
|
||||||
|
if (!GetColorDirectoryW( NULL, NULL, &size ) && GetLastError() == ERROR_MORE_DATA)
|
||||||
|
{
|
||||||
|
size += (strlenW( profile->pProfileData ) + 2) * sizeof(WCHAR);
|
||||||
|
if (!(path = HeapAlloc( GetProcessHeap(), 0, size ))) return NULL;
|
||||||
|
GetColorDirectoryW( NULL, path, &size );
|
||||||
|
PathAddBackslashW( path );
|
||||||
|
strcatW( path, profile->pProfileData );
|
||||||
|
}
|
||||||
|
else return NULL;
|
||||||
|
handle = CreateFileW( path, flags, sharing, NULL, creation, 0, NULL );
|
||||||
|
HeapFree( GetProcessHeap(), 0, path );
|
||||||
|
}
|
||||||
if (handle == INVALID_HANDLE_VALUE)
|
if (handle == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
WARN( "Unable to open color profile %u\n", GetLastError() );
|
WARN( "Unable to open color profile %u\n", GetLastError() );
|
||||||
|
|
|
@ -952,6 +952,16 @@ static void test_OpenColorProfileA(void)
|
||||||
|
|
||||||
ret = pCloseColorProfile( handle );
|
ret = pCloseColorProfile( handle );
|
||||||
ok( ret, "CloseColorProfile() failed (%d)\n", GetLastError() );
|
ok( ret, "CloseColorProfile() failed (%d)\n", GetLastError() );
|
||||||
|
|
||||||
|
profile.dwType = PROFILE_FILENAME;
|
||||||
|
profile.pProfileData = (void *)"sRGB Color Space Profile.icm";
|
||||||
|
profile.cbDataSize = sizeof("sRGB Color Space Profile.icm");
|
||||||
|
|
||||||
|
handle = pOpenColorProfileA( &profile, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING );
|
||||||
|
ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
|
||||||
|
|
||||||
|
ret = pCloseColorProfile( handle );
|
||||||
|
ok( ret, "CloseColorProfile() failed (%d)\n", GetLastError() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue