Windows: add AFSRetrieveParentPath()
authorPeter Scott <pscott@kerneldrivers.com>
Wed, 2 Nov 2011 14:18:09 +0000 (10:18 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 2 Nov 2011 18:04:24 +0000 (11:04 -0700)
Change-Id: Ic3da7f09f12f0e089b9561a542b2cf04ff61c98d
Reviewed-on: http://gerrit.openafs.org/5783
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp
src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h

index 3fa2e59..56b2def 100644 (file)
@@ -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
index 24125fa..c51ae08 100644 (file)
@@ -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
 //