Exemplo n.º 1
0
        internal static int GetLongPathName(string path, [Out] StringBuilder longPathBuffer, int bufferLength)
        {
            bool wasExtended = PathInternal.IsExtended(path);

            if (!wasExtended)
            {
                path = PathInternal.EnsureExtendedPrefixOverMaxPath(path);
            }
            int result = GetLongPathNamePrivate(path, longPathBuffer, longPathBuffer.Capacity);

            if (!wasExtended)
            {
                // We don't want to give back \\?\ if we possibly added it ourselves
                PathInternal.RemoveExtendedPrefix(longPathBuffer);
            }
            return(result);
        }
Exemplo n.º 2
0
        internal static int GetFullPathName(string path, int numBufferChars, [Out] StringBuilder buffer, IntPtr mustBeZero)
        {
            bool wasExtended = PathInternal.IsExtended(path);

            if (!wasExtended)
            {
                path = PathInternal.EnsureExtendedPrefixOverMaxPath(path);
            }
            int result = GetFullPathNamePrivate(path, buffer.Capacity, buffer, mustBeZero);

            if (!wasExtended)
            {
                // We don't want to give back \\?\ if we possibly added it ourselves
                PathInternal.RemoveExtendedPrefix(buffer);
            }
            return(result);
        }
Exemplo n.º 3
0
        internal static int GetFullPathName(string path, int numBufferChars, [Out] StringBuilder buffer)
        {
            // GetFullPathName is backwards from most APIs. It handles long "DOS" paths without a problem. While it understands
            // extended paths (\\?\), it roots them incorrectly, eating into the volume name with relative paths.

            PathInternal.ExtendedType extendedType = PathInternal.RemoveExtendedPrefix(ref path);
            int result = GetFullPathNamePrivate(path, buffer.Capacity, buffer, IntPtr.Zero);

            if ((extendedType & PathInternal.ExtendedType.Extended) != 0)
            {
                // We want to *always* give back whatever we removed
                if (extendedType.HasFlag(PathInternal.ExtendedType.ExtendedUnc))
                {
                    buffer.Insert(2, PathInternal.UncExtendedPrefixToInsert);
                }
                else
                {
                    buffer.Insert(0, PathInternal.ExtendedPathPrefix);
                }
            }
            return(result);
        }