public static FtpListItem Parse(string path, string buf, FtpCapability capabilities)
{
if (buf != null && buf.Length > 0) {
FtpListItem item;
foreach (Parser parser in Parsers) {
if ((item = parser(buf, capabilities)) != null) {
// if this is a vax/openvms file listing
// there are no slashes in the path name
if (parser == (new Parser(ParseVaxList)))
item.FullName = path + item.Name;
else {
FtpTrace.WriteLine(item.Name);
// remove globbing/wildcard from path
if (path.GetFtpFileName().Contains("*")) {
path = path.GetFtpDirectoryName();
}
item.FullName = path.GetFtpPath(item.Name); //.GetFtpPathWithoutGlob();
// if a link target is set and it doesn't include an absolute path
// then try to resolve it.
if (item.LinkTarget != null && !item.LinkTarget.StartsWith("/")) {
if (item.LinkTarget.StartsWith("./"))
item.LinkTarget = path.GetFtpPath(item.LinkTarget.Remove(0, 2));
else
item.LinkTarget = path.GetFtpPath(item.LinkTarget);
}
}
item.Input = buf;
return item;
}
}
}
return null;
}