#include "lcms_api.h"
#undef LCMS_API_FUNCTION
+#define IS_SEPARATOR(ch) ((ch) == '\\' || (ch) == '/')
+
+static void MSCMS_basename( LPCWSTR path, LPWSTR name )
+{
+ INT i = lstrlenW( path );
+
+ while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
+ lstrcpyW( name, &path[i] );
+}
+
WINE_DEFAULT_DEBUG_CHANNEL(mscms);
BOOL WINAPI GetColorDirectoryA( PCSTR machine, PSTR buffer, PDWORD size )
HeapFree( GetProcessHeap(), 0, bufferW );
}
-
return ret;
}
if (len <= *size)
{
- lstrcatW( buffer, colordir );
+ lstrcpyW( buffer, colordir );
return TRUE;
}
ret = InstallColorProfileW( NULL, profileW );
HeapFree( GetProcessHeap(), 0, profileW );
}
-
return ret;
}
BOOL WINAPI InstallColorProfileW( PCWSTR machine, PCWSTR profile )
{
- FIXME( "( %s ) stub\n", debugstr_w(profile) );
+ WCHAR dest[MAX_PATH], base[MAX_PATH];
+ DWORD size = sizeof(dest);
+ static const WCHAR slash[] = { '\\', 0 };
+
+ TRACE( "( %s )\n", debugstr_w(profile) );
if (machine || !profile) return FALSE;
- return FALSE;
+ if (!GetColorDirectoryW( machine, dest, &size )) return FALSE;
+
+ MSCMS_basename( profile, base );
+
+ lstrcatW( dest, slash );
+ lstrcatW( dest, base );
+
+ /* Is source equal to destination? */
+ if (!lstrcmpW( profile, dest )) return TRUE;
+
+ return CopyFileW( profile, dest, TRUE );
}
BOOL WINAPI UninstallColorProfileA( PCSTR machine, PCSTR profile, BOOL delete )
{
+ UINT len;
+ LPWSTR profileW;
+ BOOL ret = FALSE;
+
+ TRACE( "( %s )\n", debugstr_a(profile) );
+
if (machine || !profile) return FALSE;
- if (delete)
- return DeleteFileA( profile );
+ len = MultiByteToWideChar( CP_ACP, 0, profile, -1, NULL, 0 );
+ profileW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
- return TRUE;
+ if (profileW)
+ {
+ MultiByteToWideChar( CP_ACP, 0, profile, -1, profileW, len );
+
+ ret = UninstallColorProfileW( NULL, profileW , delete );
+
+ HeapFree( GetProcessHeap(), 0, profileW );
+ }
+ return ret;
}
BOOL WINAPI UninstallColorProfileW( PCWSTR machine, PCWSTR profile, BOOL delete )
HeapFree( GetProcessHeap(), 0, profileW.pProfileData );
}
}
-
return handle;
}
'\\','c','o','l','o','r','\\','s','r','g','b',' ','c','o','l','o','r',' ',
's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 };
-static LPSTR standardprofile = NULL;
-static LPWSTR standardprofileW = NULL;
+static LPSTR standardprofile;
+static LPWSTR standardprofileW;
-static LPSTR testprofile = NULL;
-static LPWSTR testprofileW = NULL;
+static LPSTR testprofile;
+static LPWSTR testprofileW;
+
+#define IS_SEPARATOR(ch) ((ch) == '\\' || (ch) == '/')
+
+static void MSCMS_basenameA( LPCSTR path, LPSTR name )
+{
+ INT i = strlen( path );
+
+ while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
+ strcpy( name, &path[i] );
+}
+
+static void MSCMS_basenameW( LPCWSTR path, LPWSTR name )
+{
+ INT i = lstrlenW( path );
+
+ while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
+ lstrcpyW( name, &path[i] );
+}
static void test_GetColorDirectoryA()
{
ok( !ret, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() );
ret = InstallColorProfileA( NULL, machine );
- ok( !ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
+ ok( !ret, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() );
if (standardprofile)
{
if (testprofile)
{
+ CHAR dest[MAX_PATH], base[MAX_PATH];
+ DWORD size = sizeof(dest);
+ CHAR slash[] = "\\";
+ HANDLE handle;
+
ret = InstallColorProfileA( NULL, testprofile );
ok( ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
- ret = UninstallColorProfileA( NULL, testprofile, TRUE );
+ ret = GetColorDirectoryA( NULL, dest, &size );
+ ok( ret, "GetColorDirectoryA() failed (%ld)\n", GetLastError() );
+
+ MSCMS_basenameA( testprofile, base );
+
+ strcat( dest, slash );
+ strcat( dest, base );
+
+ /* Check if the profile is really there */
+ handle = CreateFileA( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
+ ok( handle != INVALID_HANDLE_VALUE, "Couldn't find the profile (%ld)\n", GetLastError() );
+ CloseHandle( handle );
+
+ ret = UninstallColorProfileA( NULL, dest, TRUE );
ok( ret, "UninstallColorProfileA() failed (%ld)\n", GetLastError() );
}
}
if (testprofileW)
{
+ WCHAR dest[MAX_PATH], base[MAX_PATH];
+ DWORD size = sizeof(dest);
+ WCHAR slash[] = { '\\', 0 };
+ HANDLE handle;
+
ret = InstallColorProfileW( NULL, testprofileW );
ok( ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
- ret = UninstallColorProfileW( NULL, testprofileW, TRUE );
+ ret = GetColorDirectoryW( NULL, dest, &size );
+ ok( ret, "GetColorDirectoryW() failed (%ld)\n", GetLastError() );
+
+ MSCMS_basenameW( testprofileW, base );
+
+ lstrcatW( dest, slash );
+ lstrcatW( dest, base );
+
+ /* Check if the profile is really there */
+ handle = CreateFileW( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
+ ok( handle != INVALID_HANDLE_VALUE, "Couldn't find the profile (%ld)\n", GetLastError() );
+ CloseHandle( handle );
+
+ ret = UninstallColorProfileW( NULL, dest, TRUE );
ok( ret, "UninstallColorProfileW() failed (%ld)\n", GetLastError() );
}
}
if (testprofile)
{
+ CHAR dest[MAX_PATH], base[MAX_PATH];
+ DWORD size = sizeof(dest);
+ CHAR slash[] = "\\";
+ HANDLE handle;
+
ret = InstallColorProfileA( NULL, testprofile );
ok( ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
- ret = UninstallColorProfileA( NULL, testprofile, TRUE );
+ ret = GetColorDirectoryA( NULL, dest, &size );
+ ok( ret, "GetColorDirectoryA() failed (%ld)\n", GetLastError() );
+
+ MSCMS_basenameA( testprofile, base );
+
+ strcat( dest, slash );
+ strcat( dest, base );
+
+ ret = UninstallColorProfileA( NULL, dest, TRUE );
ok( ret, "UninstallColorProfileA() failed (%ld)\n", GetLastError() );
+
+ /* Check if the profile is really gone */
+ handle = CreateFileA( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
+ ok( handle == INVALID_HANDLE_VALUE, "Found the profile (%ld)\n", GetLastError() );
+ CloseHandle( handle );
}
}
if (testprofileW)
{
+ WCHAR dest[MAX_PATH], base[MAX_PATH];
+ DWORD size = sizeof(dest);
+ WCHAR slash[] = { '\\', 0 };
+ HANDLE handle;
+
ret = InstallColorProfileW( NULL, testprofileW );
ok( ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
- ret = UninstallColorProfileW( NULL, testprofileW, TRUE );
+ ret = GetColorDirectoryW( NULL, dest, &size );
+ ok( ret, "GetColorDirectoryW() failed (%ld)\n", GetLastError() );
+
+ MSCMS_basenameW( testprofileW, base );
+
+ lstrcatW( dest, slash );
+ lstrcatW( dest, base );
+
+ ret = UninstallColorProfileW( NULL, dest, TRUE );
ok( ret, "UninstallColorProfileW() failed (%ld)\n", GetLastError() );
+
+ /* Check if the profile is really gone */
+ handle = CreateFileW( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
+ ok( handle == INVALID_HANDLE_VALUE, "Found the profile (%ld)\n", GetLastError() );
+ CloseHandle( handle );
}
}