Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Allow extended long path directories #2700

Merged
merged 1 commit into from
Aug 10, 2015

Conversation

JeremyKuhne
Copy link
Member

Add methods for checking max length as it varies on path format.

Most code paths hit PathTooLong with GetFullPath- directories are a special
case as Win32 apis have a special limit (248) for directory creation.
#2581, #2411, #2579

@stephentoub, @mmitche, @weshaggard

/// </summary>
internal static bool IsPathTooLong(string fullPath)
{
return fullPath.Length >= Interop.libc.MaxPath;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is == considered too long? Is MaxPath defined to be one larger than the longest path allowed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see from reading further in the changes that we were already doing this comparison, so this isn't new. Is it correct though, on both Unix and Windows?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe so (as .NET doesn't count the null terminator).

@stephentoub
Copy link
Member

Other than a few minor comments and the Unix compilation failures (looks like you're missing a .cs file in one or more .csproj files), LGTM.

cc: @ianhays

@@ -21,7 +21,11 @@ internal static class IOInputs
// Unix values vary system to system; just using really long values here likely to be more than on the average system
public static readonly int MaxDirectory = 247; // Does not include trailing \0. This the maximum length that can be passed to APIs taking directory names, such as Directory.CreateDirectory, Directory.Move
public static readonly int MaxPath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? 259 : 10000; // Does not include trailing \0.
public static readonly int MaxComponent = 255;
public static readonly int MaxExtendedPath = short.MaxValue - 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -1 is because of trailing \0 right? I'd suggest adding a comment like above that highlights this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as above. I'll add the comment.

Add methods for checking max length as it varies on path format.

Most code paths hit PathTooLong with GetFullPath- directories are a special
case as Win32 apis have a special limit (248) for directory creation.
else
{
// Will need to be updated with #2581 to allow all paths to MaxExtendedPath
// minus legth of extended local or UNC prefix.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: le_n_gth

JeremyKuhne added a commit that referenced this pull request Aug 10, 2015
Allow extended long path directories
@JeremyKuhne JeremyKuhne merged commit c6b0d8f into dotnet:master Aug 10, 2015
@JeremyKuhne JeremyKuhne deleted the AllowLongExtended branch August 10, 2015 17:42
@PureKrome
Copy link

🎉 ✨ 🎈

@niemyjski
Copy link

YAY!

@nzthiago
Copy link

image

@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Allow extended long path directories

Commit migrated from dotnet/corefx@c6b0d8f
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.