}
hFile = CreateFileA(szFullPath, GENERIC_READ | GENERIC_WRITE, 0, NULL,
- CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
+ CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hFile == INVALID_HANDLE_VALUE)
- hFile = 0;
- else if (node)
+ if (hFile != INVALID_HANDLE_VALUE && node)
node->DoExtract = FALSE;
}
{
HRESULT res = S_OK;
HFDI hfdi;
- char *str, *path, *name;
+ char *str, *end, *path = NULL, *name = NULL;
- TRACE("(%p, %s)\n", dest, szCabName);
+ TRACE("(%p, %s)\n", dest, debugstr_a(szCabName));
hfdi = FDICreate(mem_alloc,
mem_free,
}
lstrcpyA(str, szCabName);
- path = str;
- name = strrchr(path, '\\');
- if (name)
- *name++ = 0;
+ if ((end = strrchr(str, '\\')))
+ {
+ path = str;
+ end++;
+ name = HeapAlloc( GetProcessHeap(), 0, strlen(end) + 1 );
+ if (!name)
+ {
+ res = E_OUTOFMEMORY;
+ goto end;
+ }
+ strcpy( name, end );
+ *end = 0;
+ }
else
{
- name = path;
+ name = str;
path = NULL;
}
fdi_notify_extract, NULL, dest))
res = HRESULT_FROM_WIN32(GetLastError());
- HeapFree(GetProcessHeap(), 0, str);
end:
-
+ HeapFree(GetProcessHeap(), 0, path);
+ HeapFree(GetProcessHeap(), 0, name);
FDIDestroy(hfdi);
-
return res;
}