Commit 72000726 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

mscms: Fix OpenColorProfile to handle relative file names.

parent 7c527199
MODULE = mscms.dll
IMPORTLIB = mscms
IMPORTS = advapi32
IMPORTS = shlwapi advapi32
EXTRALIBS = @LCMSLIBS@
C_SRCS = \
......
......@@ -30,6 +30,7 @@
#include "wingdi.h"
#include "winuser.h"
#include "winreg.h"
#include "shlwapi.h"
#include "icm.h"
#include "mscms_priv.h"
......@@ -1470,7 +1471,25 @@ HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing
if (!flags) return NULL;
if (!sharing) sharing = FILE_SHARE_READ;
handle = CreateFileW( profile->pProfileData, flags, sharing, NULL, creation, 0, NULL );
if (!PathIsRelativeW( profile->pProfileData ))
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)
{
WARN( "Unable to open color profile %u\n", GetLastError() );
......
......@@ -952,6 +952,16 @@ static void test_OpenColorProfileA(void)
ret = pCloseColorProfile( handle );
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() );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment