Author: hbelusca Date: Tue Sep 24 22:16:30 2013 New Revision: 60348
URL: http://svn.reactos.org/svn/reactos?rev=60348&view=rev Log: [RTL] Implement and export RtlGetLengthWithoutTrailingPathSeperators (aka. RtlGetLengthWithoutTrailingPathSeparators) (needed for win2k3's basesrv.dll). Patch by David Quintana, where I simplified the loop (and reduced the number of local variables). CORE-7482 #comment Function committed in revision 60348, thanks ;)
Modified: trunk/reactos/dll/ntdll/def/ntdll.spec trunk/reactos/include/ndk/rtlfuncs.h trunk/reactos/lib/rtl/path.c
Modified: trunk/reactos/dll/ntdll/def/ntdll.spec URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/def/ntdll.spec?re... ============================================================================== --- trunk/reactos/dll/ntdll/def/ntdll.spec [iso-8859-1] (original) +++ trunk/reactos/dll/ntdll/def/ntdll.spec [iso-8859-1] Tue Sep 24 22:16:30 2013 @@ -630,7 +630,7 @@ @ stdcall RtlGetLastWin32Error() @ stdcall RtlGetLengthWithoutLastFullDosOrNtPathElement(long ptr ptr) ; Yes, Microsoft really misspelled this one! -;@ stdcall RtlGetLengthWithoutTrailingPathSeperators +@ stdcall RtlGetLengthWithoutTrailingPathSeperators(long ptr ptr) RtlGetLengthWithoutTrailingPathSeparators @ stdcall RtlGetLongestNtPathLength() @ stdcall RtlGetNativeSystemInformation(long long long long) NtQuerySystemInformation @ stdcall RtlGetNextRange(ptr ptr long)
Modified: trunk/reactos/include/ndk/rtlfuncs.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/rtlfuncs.h?rev=... ============================================================================== --- trunk/reactos/include/ndk/rtlfuncs.h [iso-8859-1] (original) +++ trunk/reactos/include/ndk/rtlfuncs.h [iso-8859-1] Tue Sep 24 22:16:30 2013 @@ -2723,6 +2723,15 @@ _Out_opt_ PBOOLEAN NameInvalid, _Out_ RTL_PATH_TYPE* PathType, _Out_opt_ PSIZE_T LengthNeeded +); + +NTSYSAPI +NTSTATUS +NTAPI +RtlGetLengthWithoutTrailingPathSeparators( + _In_ ULONG Flags, + _In_ PCUNICODE_STRING PathString, + _Out_ PULONG Length );
NTSYSAPI
Modified: trunk/reactos/lib/rtl/path.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/path.c?rev=60348&am... ============================================================================== --- trunk/reactos/lib/rtl/path.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/path.c [iso-8859-1] Tue Sep 24 22:16:30 2013 @@ -1253,6 +1253,48 @@
/* * @implemented + * @note: the export is called RtlGetLengthWithoutTrailingPathSeperators + * (with a 'e' instead of a 'a' in "Seperators"). + */ +NTSTATUS +NTAPI +RtlGetLengthWithoutTrailingPathSeparators(IN ULONG Flags, + IN PCUNICODE_STRING PathString, + OUT PULONG Length) +{ + ULONG NumChars; + + /* Parameters validation */ + if (Length == NULL) return STATUS_INVALID_PARAMETER; + + *Length = 0; + + if (PathString == NULL) return STATUS_INVALID_PARAMETER; + + /* No flags are supported yet */ + if (Flags != 0) return STATUS_INVALID_PARAMETER; + + NumChars = PathString->Length / sizeof(WCHAR); + + /* + * Notice that we skip the last character, therefore: + * - if we have: "some/path/f" we test for: "some/path/" + * - if we have: "some/path/" we test for: "some/path" + * - if we have: "s" we test for: "" + * - if we have: "" then NumChars was already zero and we aren't there + */ + + while (NumChars > 0 && IS_PATH_SEPARATOR(PathString->Buffer[NumChars - 1])) + { + --NumChars; + } + + *Length = NumChars; + return STATUS_SUCCESS; +} + +/* + * @implemented */ RTL_PATH_TYPE NTAPI