Exemplo n.º 1
0
        // Parses a line from a Windows-format listing
        //
        // Assumes listing style as:
        // 02-03-04  07:46PM       <DIR>          Append
        protected FtpDirectoryEntry ParseWindowsDirectoryListing(string text)
        {
            FtpDirectoryEntry entry = new FtpDirectoryEntry();

            text = text.Trim();
            string dateStr = text.Substring(0, 8);
            text = text.Substring(8).Trim();
            string timeStr = text.Substring(0, 7);
            text = text.Substring(7).Trim();
            entry.CreateTime = DateTime.Parse(String.Format("{0} {1}", dateStr, timeStr));
            if (text.Substring(0, 5) == "<DIR>")
            {
                entry.IsDirectory = true;
                text = text.Substring(5).Trim();
            }
            else
            {
                entry.IsDirectory = false;
                int pos = text.IndexOf(' ');
                entry.Size = Int64.Parse(text.Substring(0, pos));
                text = text.Substring(pos).Trim();
            }
            entry.Name = text;  // Rest is name

            return entry;
        }
Exemplo n.º 2
0
 // Parses a line from a UNIX-format listing
 //
 // Assumes listing style as:
 // dr-xr-xr-x   1 owner    group               0 Nov 25  2002 bussys
 protected FtpDirectoryEntry ParseUnixDirectoryListing(string text)
 {
     // Assuming record style as
     // dr-xr-xr-x   1 owner    group               0 Nov 25  2002 bussys
     FtpDirectoryEntry entry = new FtpDirectoryEntry();
     string processstr = text.Trim();
     entry.Flags = processstr.Substring(0, 9);
     entry.IsDirectory = (entry.Flags[0] == 'd');
     processstr = (processstr.Substring(11)).Trim();
     CutSubstringWithTrim(ref processstr, ' ', 0);   //skip one part
     entry.Owner = CutSubstringWithTrim(ref processstr, ' ', 0);
     entry.Group = CutSubstringWithTrim(ref processstr, ' ', 0);
     CutSubstringWithTrim(ref processstr, ' ', 0);   //skip one part
     entry.CreateTime = DateTime.Parse(CutSubstringWithTrim(ref processstr, ' ', 8));
     entry.Name = processstr;   //Rest of the part is name
     return entry;
 }