MSI: produce short filenames when formating record
Aric Stewart
aric at codeweavers.com
Tue May 24 12:37:55 CDT 2005
implement the [!file] format to produce the short filename.
-------------- next part --------------
Index: dlls/msi/format.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/format.c,v
retrieving revision 1.12
diff -u -r1.12 format.c
--- dlls/msi/format.c 18 Apr 2005 15:36:59 -0000 1.12
+++ dlls/msi/format.c 24 May 2005 17:37:15 -0000
@@ -101,7 +101,8 @@
return value;
}
-static LPWSTR deformat_file(MSIPACKAGE* package, LPCWSTR key, DWORD* sz)
+static LPWSTR deformat_file(MSIPACKAGE* package, LPCWSTR key, DWORD* sz,
+ BOOL shortname)
{
LPWSTR value = NULL;
INT index;
@@ -114,8 +115,32 @@
index = get_loaded_file(package,key);
if (index >=0)
{
- value = strdupW(package->files[index].TargetPath);
- *sz = (strlenW(value)) * sizeof(WCHAR);
+ if (!shortname)
+ {
+ value = strdupW(package->files[index].TargetPath);
+ *sz = (strlenW(value)) * sizeof(WCHAR);
+ }
+ else
+ {
+ DWORD size = 0;
+ size = GetShortPathNameW(package->files[index].TargetPath, NULL, 0);
+
+ if (size > 0)
+ {
+ *sz = (size-1) * sizeof (WCHAR);
+ size ++;
+ value = HeapAlloc(GetProcessHeap(),0,size * sizeof(WCHAR));
+ GetShortPathNameW(package->files[index].TargetPath, value,
+ size);
+ }
+ else
+ {
+ ERR("Unable to get ShortPath size (%s)\n",
+ debugstr_w(package->files[index].TargetPath));
+ value = NULL;
+ *sz = 0;
+ }
+ }
}
return value;
@@ -378,8 +403,10 @@
value = deformat_component(package,&key[1],&chunk);
break;
case '#':
+ value = deformat_file(package,&key[1], &chunk, FALSE);
+ break;
case '!': /* should be short path */
- value = deformat_file(package,&key[1], &chunk);
+ value = deformat_file(package,&key[1], &chunk, TRUE);
break;
case '\\':
value = deformat_escape(&key[1],&chunk);
More information about the wine-patches
mailing list