Skip to content

Commit

Permalink
Replacement of path resolving in GetNameListing with code from GetLis…
Browse files Browse the repository at this point in the history
…ting.
  • Loading branch information
Yuriy Gromchenko committed Jan 6, 2014
1 parent 76845c7 commit 8cbb436
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/System.Net.FtpClient/bin
/System.Net.FtpClient/obj
17 changes: 16 additions & 1 deletion System.Net.FtpClient/FtpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2020,13 +2020,28 @@ public string[] GetNameListing(string path) {
List<string> lst = new List<string>();
string pwd = GetWorkingDirectory();

if (path == null || path.GetFtpPath().Trim().Length == 0 || path.StartsWith(".")) {
/*if (path == null || path.GetFtpPath().Trim().Length == 0 || path.StartsWith(".")) {
if (pwd == null || pwd.Length == 0) // couldn't get the working directory
path = "./";
else if (path.StartsWith("./"))
path = string.Format("{0}/{1}", pwd, path.Remove(0, 2));
else
path = pwd;
}*/

path = path.GetFtpPath();
if (path == null || path.Trim().Length == 0)
{
if (pwd != null && pwd.Trim().Length > 0)
path = pwd;
else
path = "./";
}
else if (!path.StartsWith("/") && pwd != null && pwd.Trim().Length > 0)
{
if (path.StartsWith("./"))
path = path.Remove(0, 2);
path = string.Format("{0}/{1}", pwd, path).GetFtpPath();
}

try {
Expand Down
2 changes: 1 addition & 1 deletion System.Net.FtpClient/FtpExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class FtpExtensions {
/// <param name="path">The file system path</param>
/// <returns>A path formatted for FTP</returns>
public static string GetFtpPath(this string path) {
if (path == null || path.Length == 0)
if (String.IsNullOrEmpty(path))
return "./";

path = Regex.Replace(path.Replace('\\', '/'), "[/]+", "/").TrimEnd('/');
Expand Down

0 comments on commit 8cbb436

Please sign in to comment.