/// <summary> /// Method to parse a line of file listing data from the FTP server. /// </summary> /// <param name="line">Line to parse.</param> /// <returns>Object representing data in parsed file listing line.</returns> public FtpItem ParseLine(string line) { if (String.IsNullOrEmpty(line)) { throw new FtpItemParsingException("line cannot be empty"); } Parse(line); FtpMlsxItem m = new FtpMlsxItem(_name, _modified, _size, _itemType, _attributes, _unixMode, _lang, _create, _unique, _perm, _lang, _mediaType, _charSet, _unixGroup, _unixOwner); return(m); }
/// <summary> /// Convert current FtpCollection to a DataTable object. /// </summary> /// <returns>Data table object.</returns> public DataTable ToDataTable() { DataTable dataTbl = new DataTable(); dataTbl.Locale = CultureInfo.InvariantCulture; bool mlsx = false; if (_list.Count > 0) { if (_list[0] is FtpMlsxItem) { mlsx = true; } } CreateColumns(dataTbl, mlsx); foreach (FtpItem item in _list) { // skip parent and current directory items to get consistent data if (item.ItemType == FtpItemType.ParentDirectory || item.ItemType == FtpItemType.CurrentDirectory) { continue; } DataRow row = dataTbl.NewRow(); // set standard row columns for FtpItem object row[COL_NAME] = item.Name; row[COL_MODIFIED] = item.Modified == null ? DateTime.MinValue : item.Modified; row[COL_SIZE] = item.Size; row[COL_TYPE] = item.ItemType.ToString(); row[COL_ATTRIBUTES] = item.Attributes == null ? String.Empty : item.Attributes; row[COL_SYMBOLIC_LINK] = item.SymbolicLink == null ? String.Empty : item.SymbolicLink; row[COL_RAW_TEXT] = item.RawText == null ? String.Empty : item.RawText; row[COL_MODE] = item.Mode == null ? 0 : item.Mode; // set MLSx specific columns if the object is a FtpMlsxItem object if (mlsx) { FtpMlsxItem mitem = (FtpMlsxItem)item; row[COL_MLSX_CREATED] = mitem.Created == null ? DateTime.MinValue : mitem.Created;; row[COL_MLSX_UNIQUE_ID] = mitem.UniqueId == null ? String.Empty : mitem.UniqueId; row[COL_MLSX_PERMISSIONS] = mitem.Permissions.ToString(); row[COL_MLSX_LANGUAGE] = mitem.Language == null ? String.Empty : mitem.Language; row[COL_MLSX_MEDIA_TYPE] = mitem.MediaType == null ? String.Empty : mitem.MediaType; row[COL_MLSX_CHARACTER_SET] = mitem.CharacterSet == null ? String.Empty : mitem.CharacterSet; row[COL_MLSX_GROUP] = mitem.Group == null ? 0 : mitem.Group; row[COL_MLSX_OWNER] = mitem.Owner == null ? 0 : mitem.Owner; } dataTbl.Rows.Add(row); } return(dataTbl); }
/// <summary> /// Creates a clone of the item object. /// </summary> /// <returns>Returns a FtpMlsxItem clone.</returns> public override FtpItem Clone() { FtpMlsxItem c = new FtpMlsxItem(base.Name, base.Modified, base.Size, base.ItemType, base.Attributes, base.Mode, base.RawText, _created, _uniqueId, _permissions, _language, _mediaType, _characterSet, _group, _owner); return(c); }