From cddb3baa13b1c941533bee5cdf0873ca4563c9c1 Mon Sep 17 00:00:00 2001 From: Peter Scott Date: Wed, 2 Nov 2011 10:18:09 -0400 Subject: [PATCH] Windows: add AFSRetrieveParentPath() Change-Id: Ic3da7f09f12f0e089b9561a542b2cf04ff61c98d Reviewed-on: http://gerrit.openafs.org/5783 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp | 32 +++++++++++++++++++ .../afsrdr/kernel/lib/Include/AFSCommon.h | 4 +++ 2 files changed, 36 insertions(+) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp b/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp index 3fa2e5922..56b2defc8 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp @@ -8243,3 +8243,35 @@ try_exit: return ntStatus; } + +void +AFSRetrieveParentPath( IN UNICODE_STRING *FullFileName, + OUT UNICODE_STRING *ParentPath) +{ + + USHORT usIndex = 0; + + *ParentPath = *FullFileName; + + // + // If the final character is a \, jump over it + // + + if( ParentPath->Buffer[ (ParentPath->Length/sizeof( WCHAR)) - 1] == L'\\') + { + ParentPath->Length -= sizeof( WCHAR); + } + + while( ParentPath->Buffer[ (ParentPath->Length/sizeof( WCHAR)) - 1] != L'\\') + { + ParentPath->Length -= sizeof( WCHAR); + } + + // + // And the separator + // + + ParentPath->Length -= sizeof( WCHAR); + + return; +} \ No newline at end of file diff --git a/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h b/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h index 24125fad3..c51ae0885 100644 --- a/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h +++ b/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h @@ -1342,6 +1342,10 @@ AFSValidNameFormat( IN UNICODE_STRING *FileName); NTSTATUS AFSCreateDefaultSecurityDescriptor( void); +void +AFSRetrieveParentPath( IN UNICODE_STRING *FullFileName, + OUT UNICODE_STRING *ParentPath); + // // AFSWorker.cpp Prototypes // -- 2.39.5