From 74c5e8c73ace5043a1a78b479d7b701be3f5966d Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sat, 28 Jul 2007 16:00:35 +0000 Subject: * ntdll.h (RtlInitCountedUnicodeString): Swap order of string and length parameters to be the same as for RtlInitEmptyUnicodeString. (RtlEqualPathPrefix): New inline function. (RtlEqualPathSuffix): New inline function. * fhandler_disk_file.cc: Accommodate parameter order change of RtlInitEmptyUnicodeString throughout. (fhandler_disk_file::link): Do path checking in unicode. Call CopyFileW instead of CopyFileA. --- winsup/cygwin/ntdll.h | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'winsup/cygwin/ntdll.h') diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h index aca672533..c30aed15c 100644 --- a/winsup/cygwin/ntdll.h +++ b/winsup/cygwin/ntdll.h @@ -807,8 +807,8 @@ extern "C" dest->Buffer = (PWSTR) buf; } inline - VOID NTAPI RtlInitCountedUnicodeString (PUNICODE_STRING dest, USHORT len, - PCWSTR buf) + VOID NTAPI RtlInitCountedUnicodeString (PUNICODE_STRING dest, PCWSTR buf, + USHORT len) { dest->Length = dest->MaximumLength = len; dest->Buffer = (PWSTR) buf; @@ -822,9 +822,36 @@ extern "C" ; ++len; if (dir) - RtlInitCountedUnicodeString (dir, len * sizeof (WCHAR), path->Buffer); + RtlInitCountedUnicodeString (dir, path->Buffer, len * sizeof (WCHAR)); if (file) - RtlInitCountedUnicodeString (file, path->Length - len * sizeof (WCHAR), - &path->Buffer[len]); + RtlInitCountedUnicodeString (file, &path->Buffer[len], + path->Length - len * sizeof (WCHAR)); + } + inline + BOOLEAN NTAPI RtlEqualPathPrefix (PUNICODE_STRING path, PCWSTR prefix, + BOOLEAN caseinsensitive) + { + UNICODE_STRING p, pref; + + RtlInitUnicodeString (&pref, prefix); + RtlInitCountedUnicodeString (&p, path->Buffer, + pref.Length < path->Length + ? pref.Length : path->Length); + return RtlEqualUnicodeString (&p, &pref, caseinsensitive); + } + inline + BOOL NTAPI RtlEqualPathSuffix (PUNICODE_STRING path, PCWSTR suffix, + BOOLEAN caseinsensitive) + { + UNICODE_STRING p, suf; + + RtlInitUnicodeString (&suf, suffix); + if (suf.Length < path->Length) + RtlInitCountedUnicodeString (&p, (PWCHAR) ((PBYTE) path->Buffer + + path->Length - suf.Length), + suf.Length); + else + RtlInitCountedUnicodeString (&p, path->Buffer, path->Length); + return RtlEqualUnicodeString (&p, &suf, caseinsensitive); } } -- cgit v1.2.3