public LinkedList<FTPEntry> ListEntries()
{
var entries = new LinkedList<FTPEntry>();
int defalt_year = DateTime.Now.Year;
foreach (var row in List())
{
//Console.WriteLine(row.ToString());
var matches = regex.Match(row.ToString());
int year = defalt_year, month = 1, day = 1, hour = 0, minute = 0, second = 0;
String year_or_hour = matches.Groups["YearOrHour"].Value;
month = MonthsMap[matches.Groups["Month"].Value.ToLower()];
day = Convert.ToInt32(matches.Groups["Day"].Value);
DateTimeRange.PrecisionType Precision;
// Hour
if (year_or_hour.IndexOf(":") >= 0)
{
var c = year_or_hour.Split(':');
hour = Convert.ToInt32(c[0]);
minute = Convert.ToInt32(c[1]);
Precision = DateTimeRange.PrecisionType.Minutes;
}
// Year
else
{
year = Convert.ToInt32(year_or_hour);
Precision = DateTimeRange.PrecisionType.Days;
}
var entry = new FTPEntry();
entry.Name = matches.Groups["FileName"].Value;
entry.RawInfo = matches.Groups["Perms"].Value;
entry.Unknown = Convert.ToInt32(matches.Groups["Unknown"].Value);
entry.UserName = matches.Groups["Uid"].Value;
entry.GroupName = matches.Groups["Gid"].Value;
if (!int.TryParse(entry.UserName, out entry.UserId))
{
entry.UserId = -1;
}
if (!int.TryParse(entry.GroupName, out entry.GroupId))
{
entry.GroupId = -1;
}
entry.Size = Convert.ToInt64(matches.Groups["Size"].Value);
entry.ModifiedTime = new DateTimeRange(new DateTime(year, month, day, hour, minute, second), Precision);
switch (entry.RawInfo[0])
{
case 'd': entry.Type = FTPEntry.FileType.Directory; break;
case '-': entry.Type = FTPEntry.FileType.File; break;
case '1': entry.Type = FTPEntry.FileType.Link; break;
}
entries.AddLast(entry);
}
return entries;
}