// edtFTPnet // // Copyright (C) 2004 Enterprise Distributed Technologies Ltd // // www.enterprisedt.com // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Bug fixes, suggestions and comments should posted on // http://www.enterprisedt.com/forums/index.php // // Change Log: // // $Log: FTPFile.cs,v $ // Revision 1.4 2004/11/05 20:00:28 bruceb // cleaned up namespaces // // Revision 1.3 2004/10/29 09:41:44 bruceb // removed /// in file header // // // using System; using System.Globalization; using System.Text; namespace EnterpriseDT.Net.Ftp { /// /// Represents a remote file (implementation) /// /// /// Bruce Blackshaw /// /// /// $LastChangedRevision$ /// public class FTPFile { /// /// Get the type of file, eg UNIX /// /// the integer type of the file /// virtual public int Type { get { return type; } } /// /// Returns the name. /// virtual public string Name { get { return name; } } /// /// Returns the raw server string. /// virtual public string Raw { get { return raw; } } /// /// Returns or sets the number of links to the file /// virtual public int LinkCount { get { return linkCount; } set { this.linkCount = value; } } /// /// Is this file a link /// virtual public bool Link { get { return isLink; } set { this.isLink = value; } } /// /// Returns the linked name. /// virtual public string LinkedName { get { return linkedname; } set { this.linkedname = value; } } /// /// Gets or sets the group. /// virtual public string Group { get { return group; } set { this.group = value; } } /// /// Gets or sets the owner. /// virtual public string Owner { get { return owner; } set { this.owner = value; } } /// /// Gets or sets whether this is a directory /// virtual public bool Dir { get { return isDir; } set { this.isDir = value; } } /// /// Gets or sets the permissions. /// virtual public string Permissions { get { return permissions; } set { this.permissions = value; } } /// /// Gets last modified timestamp /// virtual public DateTime LastModified { get { return lastModified; } } /// /// Gets size of file /// virtual public long Size { get { return size; } } /// Unknown remote server type public const int UNKNOWN = - 1; /// Windows type public const int WINDOWS = 0; /// UNIX type public const int UNIX = 1; /// Date format private static readonly string format = "dd-MM-yyyy HH:mm"; /// Type of file private int type; /// Is this file a symbolic link? protected internal bool isLink = false; /// Number of links to file protected internal int linkCount = 1; /// Permission bits string protected internal string permissions; /// Is this a directory? protected internal bool isDir = false; /// Size of file protected internal long size = 0L; /// File/dir name protected internal string name; /// Name of file this is linked to protected internal string linkedname; /// Owner if known protected internal string owner; /// Group if known protected internal string group; /// Last modified protected internal System.DateTime lastModified; /// Raw string protected internal string raw; /// /// Constructor /// /// /// type of file /// /// /// raw string returned from server /// /// /// name of file /// /// /// size of file /// /// /// true if a directory /// /// /// last modified timestamp /// internal FTPFile(int type, string raw, string name, long size, bool isDir, ref DateTime lastModified) { this.type = type; this.raw = raw; this.name = name; this.size = size; this.isDir = isDir; this.lastModified = lastModified; } /// /// string representation /// public override string ToString() { StringBuilder buf = new StringBuilder(raw); buf.Append("[").Append("Name=").Append(name).Append(",").Append("Size="). Append(size).Append(",").Append("Permissions=").Append(permissions). Append(",").Append("Owner=").Append(owner).Append(","). Append("Group=").Append(group).Append(",").Append("Is link=").Append(isLink). Append(",").Append("Link count=").Append(linkCount).Append(","). Append("Is dir=").Append(isDir).Append(","). Append("Linked name=").Append(linkedname).Append(","). Append("Permissions=").Append(permissions).Append(","). Append("Last modified=").Append(lastModified.ToString(format, CultureInfo.CurrentCulture.DateTimeFormat)). Append("]"); return buf.ToString(); } } }