|
Mr. Driesen the patch is attached to the message, I hope it is ok. I'll need to take a better look at building some Unit Tests before sending something concrete. I guess that my patch code could be improved for performance and programming logic, I'll have a look at that too. Regards, Rodrigo PS: Sorry for the previous e-mail, my email client was misconfigured. Gert Driesen wrote: ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[email protected]> Sent: Monday, February 28, 2005 7:38 AM Subject: [nant-dev] Path Too Long Patch |
Index: C:/nant-0.85-rc2/src/NAnt.Core/Util/FileUtils.cs
===================================================================
--- C:/nant-0.85-rc2/src/NAnt.Core/Util/FileUtils.cs (revision 28)
+++ C:/nant-0.85-rc2/src/NAnt.Core/Util/FileUtils.cs (working copy)
@@ -139,5 +139,40 @@
// return the
return new DirectoryInfo(tempFile);
}
+
+ /// <summary>
+ /// Returns Absolute Path (Fix for 260 Char Limit of
Path.GetFullPath(...))
+ /// </summary>
+ /// <param name="PathName">The Path to Resolve</param>
+ /// <returns>Path Resolved</returns>
+ public static string AbsPath(String PathName)
+ {
+ // Let's Setup Regex options
+ System.Text.RegularExpressions.RegexOptions
reOptions =
((System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace |
System.Text.RegularExpressions.RegexOptions.Multiline) |
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
+ System.Text.RegularExpressions.Regex regEx = new
System.Text.RegularExpressions.Regex(@"\\", reOptions);
+
+ // Now we split the Path by the Path Separator
+ String[] items = regEx.Split(PathName);
+ System.Collections.ArrayList arList = new
System.Collections.ArrayList();
+
+ // For each Item in the path that differs from ".."
we just add it to the ArrayList
+ for( int iCount = 0; iCount < items.Length; iCount++
)
+ {
+ // If we get a ".." Try to remove the last item
added (as if going up in the Directory Structure)
+ if( items[iCount] == ".." )
+ {
+ if( arList.Count > 0 )
+ {
+ arList.RemoveAt(arList.Count-1);
+ }
+ }
+ else
+ arList.Add(items[iCount]);
+ }
+
+ // Join everything using the Path Separator
+ return String.Join(@"\",
(String[])arList.ToArray(typeof(String)));
+ }
+
}
}
Index: C:/nant-0.85-rc2/src/NAnt.VSNet/AssemblyReferenceBase.cs
===================================================================
--- C:/nant-0.85-rc2/src/NAnt.VSNet/AssemblyReferenceBase.cs (revision 28)
+++ C:/nant-0.85-rc2/src/NAnt.VSNet/AssemblyReferenceBase.cs (working copy)
@@ -240,7 +240,7 @@
relativePath);
try {
- return Path.GetFullPath(combinedPath);
+ return FileUtils.AbsPath(combinedPath);
} catch (PathTooLongException ex) {
throw new
BuildException(string.Format(CultureInfo.InvariantCulture,
"Assembly \"{0}\", referenced by project \"{1}\",
could not be"
