[1/2] winemenubuilder: Use the same icon name on Mac OS X as on Unix.
Francois Gouget
fgouget at codeweavers.com
Thu Nov 1 17:20:13 CDT 2012
---
I don't see a reason to use a different name for Mac OS X. Note that we
could probably just as well use the Mac OS X name on Unix if that's
preferred. I don't mind either way.
programs/winemenubuilder/winemenubuilder.c | 82 ++++++++++++----------------
1 file changed, 36 insertions(+), 46 deletions(-)
diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c
index 0887f19..34fc37e 100644
--- a/programs/winemenubuilder/winemenubuilder.c
+++ b/programs/winemenubuilder/winemenubuilder.c
@@ -199,7 +199,6 @@ static WCHAR* assoc_query(ASSOCSTR assocStr, LPCWSTR name, LPCWSTR extra);
static HRESULT open_icon(LPCWSTR filename, int index, BOOL bWait, IStream **ppStream);
/* Utility routines */
-#ifndef __APPLE__
static unsigned short crc16(const char* string)
{
unsigned short crc = 0;
@@ -218,7 +217,6 @@ static unsigned short crc16(const char* string)
}
return crc;
}
-#endif
static char *strdupA( const char *str )
{
@@ -1069,6 +1067,35 @@ static HRESULT open_icon(LPCWSTR filename, int index, BOOL bWait, IStream **ppSt
return hr;
}
+static char* compute_native_identifier(int exeIndex, LPCWSTR icoPathW)
+{
+ char* nativeIdentifier;
+ char *icoPathA;
+ unsigned short crc;
+ char *basename, *ext;
+
+ icoPathA = wchars_to_utf8_chars(icoPathW);
+ if (icoPathA == NULL)
+ return NULL;
+
+ crc = crc16(icoPathA);
+ basename = strrchr(icoPathA, '\\');
+ if (basename == NULL)
+ basename = icoPathA;
+ else
+ {
+ *basename = 0;
+ basename++;
+ }
+ ext = strrchr(basename, '.');
+ if (ext)
+ *ext = 0;
+
+ nativeIdentifier = heap_printf("%04X_%s.%d", crc, basename, exeIndex);
+ HeapFree(GetProcessHeap(), 0, icoPathA);
+ return nativeIdentifier;
+}
+
#ifdef __APPLE__
#define ICNS_SLOTS 6
@@ -1102,9 +1129,6 @@ static HRESULT platform_write_icon(IStream *icoStream, int exeIndex, LPCWSTR ico
} best[ICNS_SLOTS];
int indexes[ICNS_SLOTS];
int i;
- GUID guid;
- WCHAR *guidStrW = NULL;
- char *guidStrA = NULL;
char *icnsPath = NULL;
LARGE_INTEGER zero;
HRESULT hr;
@@ -1166,26 +1190,16 @@ static HRESULT platform_write_icon(IStream *icoStream, int exeIndex, LPCWSTR ico
}
}
- hr = CoCreateGuid(&guid);
- if (FAILED(hr))
- {
- WINE_WARN("CoCreateGuid failed, error 0x%08X\n", hr);
- goto end;
- }
- hr = StringFromCLSID(&guid, &guidStrW);
- if (FAILED(hr))
- {
- WINE_WARN("StringFromCLSID failed, error 0x%08X\n", hr);
- goto end;
- }
- guidStrA = wchars_to_utf8_chars(guidStrW);
- if (guidStrA == NULL)
+ if (destFilename)
+ *nativeIdentifier = heap_printf("%s", destFilename);
+ else
+ *nativeIdentifier = compute_native_identifier(exeIndex, icoPathW);
+ if (*nativeIdentifier == NULL)
{
hr = E_OUTOFMEMORY;
- WINE_WARN("out of memory converting GUID string\n");
goto end;
}
- icnsPath = heap_printf("/tmp/%s.icns", guidStrA);
+ icnsPath = heap_printf("/tmp/%s.icns", *nativeIdentifier);
if (icnsPath == NULL)
{
hr = E_OUTOFMEMORY;
@@ -1210,8 +1224,6 @@ static HRESULT platform_write_icon(IStream *icoStream, int exeIndex, LPCWSTR ico
end:
HeapFree(GetProcessHeap(), 0, iconDirEntries);
- CoTaskMemFree(guidStrW);
- HeapFree(GetProcessHeap(), 0, guidStrA);
if (SUCCEEDED(hr))
*nativeIdentifier = icnsPath;
else
@@ -1245,10 +1257,7 @@ static HRESULT platform_write_icon(IStream *icoStream, int exeIndex, LPCWSTR ico
ICONDIRENTRY *iconDirEntries = NULL;
int numEntries;
int i;
- char *icoPathA = NULL;
char *iconsDir = NULL;
- unsigned short crc;
- char *p, *q;
HRESULT hr = S_OK;
LARGE_INTEGER zero;
@@ -1256,28 +1265,10 @@ static HRESULT platform_write_icon(IStream *icoStream, int exeIndex, LPCWSTR ico
if (FAILED(hr))
goto end;
- icoPathA = wchars_to_utf8_chars(icoPathW);
- if (icoPathA == NULL)
- {
- hr = E_OUTOFMEMORY;
- goto end;
- }
- crc = crc16(icoPathA);
- p = strrchr(icoPathA, '\\');
- if (p == NULL)
- p = icoPathA;
- else
- {
- *p = 0;
- p++;
- }
- q = strrchr(p, '.');
- if (q)
- *q = 0;
if (destFilename)
*nativeIdentifier = heap_printf("%s", destFilename);
else
- *nativeIdentifier = heap_printf("%04X_%s.%d", crc, p, exeIndex);
+ *nativeIdentifier = compute_native_identifier(exeIndex, icoPathW);
if (*nativeIdentifier == NULL)
{
hr = E_OUTOFMEMORY;
@@ -1354,7 +1345,6 @@ static HRESULT platform_write_icon(IStream *icoStream, int exeIndex, LPCWSTR ico
end:
HeapFree(GetProcessHeap(), 0, iconDirEntries);
- HeapFree(GetProcessHeap(), 0, icoPathA);
HeapFree(GetProcessHeap(), 0, iconsDir);
return hr;
}
--
1.7.10.4
More information about the wine-patches
mailing list