Skip to content

Commit bb40f24

Browse files
committed
always use Path.GetFullPath()
1 parent 994b5fa commit bb40f24

1 file changed

Lines changed: 0 additions & 21 deletions

File tree

src/Framework/PathHelpers/AbsolutePath.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -146,27 +146,6 @@ internal AbsolutePath GetCanonicalForm()
146146
return this;
147147
}
148148

149-
150-
// Note: this is a quick check to avoid calling Path.GetFullPath when it's not necessary, since it can be expensive.
151-
// It should cover the most common cases and avoid the overhead of Path.GetFullPath in those cases.
152-
153-
// Check for relative path segments "." and ".."
154-
// In absolute path those segments can not appear in the beginning of the path, only after a path separator.
155-
// This is not a precise full detection of relative segments. There is no false negatives as this might affect correctenes, but it may have false positives:
156-
// like when there is a hidden file or directory starting with a dot, or on linux the backslash and dot can be part of the file name.
157-
// In case of false positives we would call Path.GetFullPath and the result would still be correct.
158-
159-
bool hasRelativeSegment = Value.Contains("/.") || Value.Contains("\\.");
160-
161-
// Check if directory separator normalization is required (only on Windows: "/" to "\")
162-
// On unix "\" is not a valid path separator, but is a part of the file/directory name, so no normalization is needed.
163-
bool needsSeparatorNormalization = NativeMethods.IsWindows && Value.IndexOf(Path.AltDirectorySeparatorChar) >= 0;
164-
165-
if (!hasRelativeSegment && !needsSeparatorNormalization)
166-
{
167-
return this;
168-
}
169-
170149
// Use Path.GetFullPath to resolve relative segments and normalize separators.
171150
// Skip validation since Path.GetFullPath already ensures the result is absolute.
172151
return new AbsolutePath(Path.GetFullPath(Value), OriginalValue, ignoreRootedCheck: true);

0 commit comments

Comments
 (0)