Commit be4aff37 authored by Rein Klazes's avatar Rein Klazes Committed by Alexandre Julliard

Handle the cases when initdir is either invalid, or specifies a file.

parent d0779463
...@@ -1159,19 +1159,31 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd) ...@@ -1159,19 +1159,31 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
DWORD result; DWORD result;
strcpyW(tmpBuf, fodInfos->initdir); strcpyW(tmpBuf, fodInfos->initdir);
if (tmpBuf[strlenW(tmpBuf)-1] != '\\') { if( PathFileExistsW(tmpBuf) ) {
strcatW(tmpBuf, szwSlash); /* initdir does not have to be a directory. If a file is
* specified, the dir part is taken */
if( PathIsDirectoryW(tmpBuf)) {
if (tmpBuf[strlenW(tmpBuf)-1] != '\\') {
strcatW(tmpBuf, szwSlash);
}
strcatW(tmpBuf, szwStar);
}
result = GetFullPathNameW(tmpBuf, MAX_PATH, tmpBuf2, &nameBit);
if (result) {
*nameBit = 0x00;
if (fodInfos->initdir)
MemFree(fodInfos->initdir);
fodInfos->initdir = MemAlloc((strlenW(tmpBuf2) + 1)*sizeof(WCHAR));
strcpyW(fodInfos->initdir, tmpBuf2);
handledPath = TRUE;
TRACE("Value in InitDir changed to %s\n", debugstr_w(fodInfos->initdir));
}
} }
strcatW(tmpBuf, szwStar); else if (fodInfos->initdir)
result = GetFullPathNameW(tmpBuf, MAX_PATH, tmpBuf2, &nameBit); {
if (result) { MemFree(fodInfos->initdir);
*nameBit = 0x00; fodInfos->initdir = NULL;
if (fodInfos->initdir) TRACE("Value in InitDir is not an existing path, changed to (nil)\n");
MemFree(fodInfos->initdir);
fodInfos->initdir = MemAlloc((strlenW(tmpBuf2) + 1)*sizeof(WCHAR));
strcpyW(fodInfos->initdir, tmpBuf2);
handledPath = TRUE;
TRACE("Value in InitDir changed to %s\n", debugstr_w(fodInfos->initdir));
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment