Exemplo n.º 1
0
        /// <summary>
        /// Get Win32 path name for a file.
        /// </summary>
        /// <param name="file">The file to get the path from.</param>
        /// <param name="flags">Flags for the path to return.</param>
        /// <param name="throw_on_error">True to throw on error.</param>
        /// <returns>The win32 path.</returns>
        public static NtResult <string> GetWin32PathName(NtFile file, Win32PathNameFlags flags, bool throw_on_error)
        {
            StringBuilder builder = new StringBuilder(1000);

            if (Win32NativeMethods.GetFinalPathNameByHandle(file.Handle, builder, builder.Capacity, flags) == 0)
            {
                return(NtObjectUtils.MapDosErrorToStatus().CreateResultFromError <string>(throw_on_error));
            }
            return(NtStatus.STATUS_SUCCESS.CreateResult(throw_on_error, () => RemoveDevicePrefix(builder.ToString())));
        }
Exemplo n.º 2
0
 internal static extern int GetFinalPathNameByHandle(SafeKernelObjectHandle hFile, StringBuilder lpszFilePath,
                                                     int cchFilePath, Win32PathNameFlags dwFlags);
Exemplo n.º 3
0
 /// <summary>
 /// Get Win32 path name for a file.
 /// </summary>
 /// <param name="file">The file to get the path from.</param>
 /// <param name="flags">Flags for the path to return.</param>
 /// <returns>The win32 path.</returns>
 public static string GetWin32PathName(NtFile file, Win32PathNameFlags flags)
 {
     return(GetWin32PathName(file, flags, true).Result);
 }