Пример #1
0
		public FtpFileSystemEntry(FileSystem FileSystem, String Path, FTPEntry FTPEntry)
			: base(FileSystem, Path)
		{
			this.FTPEntry = FTPEntry;

			//FtpEntry.
			this.Time.LastWriteTime = FTPEntry.ModifiedTime;
			this.Size = FTPEntry.Size;
			this.UserId = FTPEntry.UserId;
			this.GroupId = FTPEntry.GroupId;
			switch (FTPEntry.Type)
			{
				case FTPEntry.FileType.Directory:
					this.Type = FileSystemEntry.EntryType.Directory;
					break;
				case FTPEntry.FileType.Link:
					this.Type = FileSystemEntry.EntryType.Link;
					break;
				default:
				case FTPEntry.FileType.File:
					this.Type = FileSystemEntry.EntryType.File;
					break;
			}
		}
Пример #2
0
        /// <summary>
        /// List FTPEntry items with the current path on the FTP connection.
        /// </summary>
        /// <returns>List of FTPEntry items</returns>
        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);
        }
Пример #3
0
        /// <summary>
        /// List FTPEntry items with the current path on the FTP connection.
        /// </summary>
        /// <returns>List of FTPEntry items</returns>
        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;
        }