mscms: Fix OpenColorProfile to handle relative file names.

This commit is contained in:
Hans Leidekker 2011-09-20 11:31:13 +02:00 committed by Alexandre Julliard
parent 7c527199b6
commit 7200072622
3 changed files with 31 additions and 2 deletions

View File

@ -1,6 +1,6 @@
MODULE = mscms.dll
IMPORTLIB = mscms
IMPORTS = advapi32
IMPORTS = shlwapi advapi32
EXTRALIBS = @LCMSLIBS@
C_SRCS = \

View File

@ -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() );

View File

@ -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() );
}
}