From 28c3c2f0f0de619864e69e8a916dd8ed7a7b5cec Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 2 Oct 2003 04:43:45 +0000 Subject: [PATCH] Fixed a couple of bugs in RtlDosSearchPath_U and RtlGetFullPathName_U. Make RtlDoesFileExists_U do something useful by calling CreateFileW for now. --- dlls/ntdll/path.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/dlls/ntdll/path.c b/dlls/ntdll/path.c index 2b92180568e..c17f3f91166 100644 --- a/dlls/ntdll/path.c +++ b/dlls/ntdll/path.c @@ -63,12 +63,14 @@ DOS_PATHNAME_TYPE WINAPI RtlDetermineDosPathNameType_U( PCWSTR path ) /****************************************************************** * RtlDoesFileExists_U * - * + * FIXME: should not use CreateFileW */ BOOLEAN WINAPI RtlDoesFileExists_U(LPCWSTR file_name) -{ - FIXME("(%s): stub\n", debugstr_w(file_name)); - +{ + HANDLE handle = CreateFileW( file_name, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, 0, 0 ); + if (handle == INVALID_HANDLE_VALUE) return FALSE; + NtClose( handle ); return TRUE; } @@ -260,11 +262,12 @@ ULONG WINAPI RtlDosSearchPath_U(LPCWSTR paths, LPCWSTR search, LPCWSTR ext, if (type == RELATIVE_PATH) { ULONG allocated = 0, needed, filelen; - WCHAR* name = NULL; + WCHAR *p, *name = NULL; filelen = 1 /* for \ */ + strlenW(search) + 1 /* \0 */; - if (strchrW(search, '.') != NULL) ext = NULL; + p = strrchrW( search, '.' ); + if (p && !strchrW( p, '\\' ) && !strchrW( p, '/')) ext = NULL; if (ext != NULL) filelen += strlenW(ext); while (*paths) @@ -394,9 +397,14 @@ static ULONG get_full_path_helper(LPCWSTR name, LPWSTR buffer, ULONG size) case RELATIVE_PATH: /* foo */ reqsize += cd->Length; - mark = cd->Length / sizeof(WCHAR); - if (reqsize <= size) - strcpyW(buffer, cd->Buffer); + if (reqsize <= size) strcpyW(buffer, cd->Buffer); + if (cd->Buffer[1] != ':') + { + ptr = strchrW(cd->Buffer + 2, '\\'); + if (ptr) ptr = strchrW(ptr + 1, '\\'); + if (!ptr) ptr = cd->Buffer + strlenW(cd->Buffer); + mark = ptr - cd->Buffer; + } break; case ABSOLUTE_PATH: /* \xxx */