Exemplo n.º 1
0
        private void Parse(string line)
        {
            // ex: Type=file;Size=1830;Modify=19940916055648;Perm=r; hatch.c
            // ex: modify=20120822211414;perm=adfr;size=2101;type=file;unique=16UF3F5;UNIX.group=49440;UNIX.mode=0744;UNIX.owner=49440; iphone_settings_icon.jpg
            // ex: modify=20030225143801;perm=adfr;size=503;type=file;unique=12U24470006;UNIX.group=0;UNIX.mode=0644;UNIX.owner=0; welcome.msg
            string[] fields = line.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            if (fields.Length == 0)
            {
                return;
            }

            // parse fact fields
            for (int i = 0; i < fields.Length - 1; i++)
            {
                ParseField(fields[i]);
            }

            // last field is always name of the object
            ParseName(fields[fields.Length - 1]);

            if (_name == ".")
            {
                _itemType = FtpItemType.CurrentDirectory;
            }
            if (_name == "..")
            {
                _itemType = FtpItemType.ParentDirectory;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor to create a new ftp item.
 /// </summary>
 /// <param name="name">Name of the item.</param>
 /// <param name="modified">Modified date and/or time of the item.</param>
 /// <param name="size">Number of bytes or size of the item.</param>
 /// <param name="itemType">Type of the item.</param>
 /// <param name="attributes">UNIX style attributes value.</param>
 /// <param name="mode">UNIX style mode value</param>
 /// <param name="rawText">The raw text of the item.</param>
 /// <param name="created">Created date.</param>
 /// <param name="uniqueId">Unique identifier.</param>
 /// <param name="permissions">File action permissions.</param>
 /// <param name="language">File language.</param>
 /// <param name="mediaType">MIME file type.</param>
 /// <param name="characterSet">Character set of the file.</param>
 /// <param name="group">UNIX style group value.</param>
 /// <param name="owner">UNIX style owner value.</param>
 public FtpsMlsxItem(string name,
                     DateTime?modified,
                     long size,
                     FtpItemType itemType,
                     string attributes,
                     Int32?mode,
                     string rawText,
                     DateTime?created,
                     string uniqueId,
                     MlsxPerm permissions,
                     string language,
                     string mediaType,
                     string characterSet,
                     string group,
                     string owner
                     ) : base(name, modified, size, itemType, attributes, mode, String.Empty, rawText)
 {
     _created      = created;
     _uniqueId     = uniqueId;
     _permissions  = permissions;
     _language     = language;
     _mediaType    = mediaType;
     _characterSet = characterSet;
     _group        = group;
     _owner        = owner;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor to create a new ftp item.
 /// </summary>
 /// <param name="name">Name of the item.</param>
 /// <param name="modified">Modified date and/or time of the item.</param>
 /// <param name="size">Number of bytes or size of the item.</param>
 /// <param name="symbolicLink">Symbolic link name.</param>
 /// <param name="attributes">Permission text for item.</param>
 /// <param name="itemType">Type of the item.</param>
 /// <param name="rawText">The raw text of the item.</param>
 public FtpItem(string name, DateTime modified, long size, string symbolicLink, string attributes, FtpItemType itemType, string rawText)
 {
     _name         = name;
     _modified     = modified;
     _size         = size;
     _symbolicLink = symbolicLink;
     _attributes   = attributes;
     _itemType     = itemType;
     _rawText      = rawText;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor to create a new ftp item.
 /// </summary>
 /// <param name="name">Name of the item.</param>
 /// <param name="modified">Modified date and/or time of the item.</param>
 /// <param name="size">Number of bytes or size of the item.</param>
 /// <param name="symbolicLink">Symbolic link name.</param>
 /// <param name="attributes">Permission text for item.</param>
 /// <param name="itemType">Type of the item.</param>
 /// <param name="rawText">The raw text of the item.</param>
 public FtpItem(string name, DateTime modified, long size, string symbolicLink, string attributes, FtpItemType itemType, string rawText)
 {
     Name         = name;
     Modified     = modified;
     Size         = size;
     SymbolicLink = symbolicLink;
     Attributes   = attributes;
     ItemType     = itemType;
     RawText      = rawText;
 }
Exemplo n.º 5
0
 private ClientItemType _ItemTypeOf(FtpItemType f)
 {
     if (f == FtpItemType.File)
     {
         return(ClientItemType.File);
     }
     if (f == FtpItemType.Directory)
     {
         return(ClientItemType.Folder);
     }
     return(ClientItemType.Other);
 }
Exemplo n.º 6
0
        FtpItem ResolveAsMsDos(string line)
        {
            Match m = _dosRegEx.Match(line);

            if (10 != m.Groups.Count)
            {
                return(null);
            }

            //looks like a DOS style
            FtpItemType itemType = FtpItemType.Unresolved;
            string      name     = null;
            long        size     = 0;

            Group dir = m.Groups["dir"];

            if (dir.Length > 0)
            {
                itemType = FtpItemType.Directory;
            }
            else
            {
                size     = long.Parse(m.Groups["size"].Value);
                itemType = FtpItemType.File;
            }

            name = m.Groups["name"].Value;

            int year = int.Parse(m.Groups["year"].Value);

            year = year > 70?(year + 1900):(year + 2000);
            int    month = int.Parse(m.Groups["month"].Value);
            int    day   = int.Parse(m.Groups["day"].Value);
            int    hour  = int.Parse(m.Groups["hour"].Value);
            string half  = m.Groups["half"].Value.ToUpper();

            if ((half == "PM") &&
                (hour >= 1) &&
                (hour <= 11))
            {
                hour += 12;
            }

            if ((half == "AM") && (hour == 12))
            {
                hour -= 12;
            }

            int      minute = int.Parse(m.Groups["min"].Value);
            DateTime dt     = new DateTime(year, month, day, hour, minute, 0, 0);

            return(new FtpItem(line, name, null, dt, size, itemType));
        }
Exemplo n.º 7
0
 /// <summary>
 /// Initialize a new instance of
 /// <see cref="BytesRoad.Net.Ftp.FtpItem">FtpItem</see> class
 /// with specified type.
 /// </summary>
 /// <param name="rawString">Raw string which represents an ftp item.</param>
 /// <param name="name">Name of the ftp item.</param>
 /// <param name="refName">
 /// Link name the ftp item points to.
 /// </param>
 /// <param name="date">
 /// Creation date of the ftp item.
 /// </param>
 /// <param name="size">Size of the ftp item.</param>
 /// <param name="type">One of the
 /// <see cref="BytesRoad.Net.Ftp.FtpItemType">FtpItemType</see>
 /// values.
 /// </param>
 /// <remarks>
 /// Note that
 /// <see cref="BytesRoad.Net.Ftp.FtpItemType.Link">FtpItemType.Link</see>
 /// is the only type of the
 /// <see cref="BytesRoad.Net.Ftp.FtpItem">FtpItem</see>
 /// class instance which requires all parameters
 /// to be valid.
 /// If type is
 /// <see cref="BytesRoad.Net.Ftp.FtpItemType.Directory">FtpItemType.Directory</see>,
 /// the <b>refName</b> and <b>size</b> has no meaning, also if type is
 /// <see cref="BytesRoad.Net.Ftp.FtpItemType.File">FtpItemType.File</see>,
 /// the <b>refName</b> has no meaning as well.
 /// </remarks>
 public FtpItem(string rawString,
                string name,
                string refName,
                DateTime date,
                long size,
                FtpItemType type)
 {
     _rawString = rawString;
     _name      = name;
     _refName   = refName;
     _date      = date;
     _size      = size;
     _type      = type;
 }
Exemplo n.º 8
0
        /* Methods
         * ---------------------------------------------------------------------------------------*/

        /// <summary>
        /// Checks whether the file exists on the server or not.
        /// </summary>
        /// <param name="remoteFilePath">The path to the remote file [minus the the host].</param>
        /// <param name="type">The type of item that is being checked.</param>
        /// <returns><c>true</c> if the file exists, otherwise, <c>false</c>.</returns>
        public bool FtpItemExists(string remoteFilePath, FtpItemType type)
        {
            // If it is an empty path were going to assume it means root
            // which is always there
            if (remoteFilePath == string.Empty)
            {
                return(true);
            }

            this._request = GetNewRequest(Host + remoteFilePath);

            if (type == FtpItemType.File)
            {
                this._request.Method = WebRequestMethods.Ftp.GetFileSize;
            }
            else
            {
                this._request.Method = WebRequestMethods.Ftp.ListDirectory;
            }

            // Exception handling for control flow is ugly, unfortunately WebResponse
            // doesn't offer a better alternative for checking if a file exists.
            try {
                this._response = ( FtpWebResponse )this._request.GetResponse();
                return(true);
            }
            catch (WebException ex) {
                return(false);
            }
            finally {
                if (this._response != null)
                {
                    this._response.Close();
                }
                this._request = null;
            }
        }
Exemplo n.º 9
0
        /* Methods
           ---------------------------------------------------------------------------------------*/
        /// <summary>
        /// Checks whether the file exists on the server or not.
        /// </summary>
        /// <param name="remoteFilePath">The path to the remote file [minus the the host].</param>
        /// <param name="type">The type of item that is being checked.</param>
        /// <returns><c>true</c> if the file exists, otherwise, <c>false</c>.</returns>
        public bool FtpItemExists( string remoteFilePath, FtpItemType type )
        {
            // If it is an empty path were going to assume it means root
            // which is always there
            if( remoteFilePath == string.Empty ) {
                return true;
            }

            this._request = GetNewRequest( Host + remoteFilePath );

            if( type == FtpItemType.File ) {
                this._request.Method = WebRequestMethods.Ftp.GetFileSize;
            }
            else {
                this._request.Method = WebRequestMethods.Ftp.ListDirectory;
            }

            // Exception handling for control flow is ugly, unfortunately WebResponse
            // doesn't offer a better alternative for checking if a file exists.
            try {
                this._response = ( FtpWebResponse )this._request.GetResponse();
                return true;
            }
            catch( WebException ex ) {
                return false;
            }
            finally {
                if( this._response != null ) { this._response.Close(); }
                this._request = null;
            }
        }
Exemplo n.º 10
0
        private void ParseField(string field)
        {
            if (String.IsNullOrEmpty(field))
            {
                throw new FtpsItemParsingException("field cannot be a null or empty value");
            }

            if (field.IndexOf('=') == -1)
            {
                throw new FtpsItemParsingException("field must contain equals '=' value");
            }

            // split the field fact
            string[] fact = field.Split('=');

            if (fact.Length != 2)
            {
                throw new FtpsItemParsingException("field must contain equals '=' value with only a name and value");
            }

            string name  = fact[0].Trim().ToLower();
            string value = fact[1].Trim();

            if (name.Length == 0)
            {
                throw new FtpsItemParsingException("field fact name cannot be empty");
            }

            switch (name)
            {
            case FACT_CHAR_SET:
                _charSet = value;
                break;

            case FACT_CREATE:
                _create = ParseDateTime(value);
                break;

            case FACT_LANG:
                _lang = value;
                break;

            case FACT_MEDIA_TYPE:
                _mediaType = value;
                break;

            case FACT_MODIFY:
                _modified = ParseDateTime(value);
                break;

            case FACT_PERM:
                _perm = ParsePerm(value);
                break;

            case FACT_SIZE:
                _size = ParseSize(value);
                break;

            case FACT_TYPE:
                _itemType = ParseType(value);
                break;

            case FACT_UNIQUE:
                _unique = value;
                break;

            case FACT_EXT_UNIX_GROUP:
                _unixGroup = value;
                break;

            case FACT_EXT_UNIX_MODE:
                _unixMode = ParseInt32(value);
                if (_unixMode != null)
                {
                    _attributes = FtpsUtilities.ModeToAttribute(_unixMode.Value);
                }
                break;

            case FACT_EXT_UNIX_OWNER:
                _unixOwner = value;
                break;

            default:
                break;
            }
        }
Exemplo n.º 11
0
 private static ClientItemType _ItemTypeOf(FtpItemType f)
 {
     if (f == FtpItemType.File)
         return ClientItemType.File;
     if (f == FtpItemType.Directory)
         return ClientItemType.Folder;
     return ClientItemType.Other;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Constructor to create a new ftp item.
 /// </summary>
 /// <param name="name">Name of the item.</param>
 /// <param name="modified">Modified date and/or time of the item.</param>
 /// <param name="size">Number of bytes or size of the item.</param>
 /// <param name="symbolicLink">Symbolic link name.</param>
 /// <param name="attributes">Permission text for item.</param>
 /// <param name="itemType">Type of the item.</param>
 /// <param name="rawText">The raw text of the item.</param>
 public FtpItem(string name, DateTime modified, long size, string symbolicLink, string attributes, FtpItemType itemType, string rawText)
 {
     _name = name;
     _modified = modified;
     _size = size;
     _symbolicLink = symbolicLink;
     _attributes = attributes;
     _itemType = itemType;
     _rawText = rawText;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Constructor to create a new ftp item.
 /// </summary>
 /// <param name="name">Name of the item.</param>
 /// <param name="modified">Modified date and/or time of the item.</param>
 /// <param name="size">Number of bytes or size of the item.</param>
 /// <param name="itemType">Type of the item.</param>
 /// <param name="attributes">UNIX style attributes value.</param>
 /// <param name="mode">UNIX style mode value</param>
 /// <param name="rawText">The raw text of the item.</param>
 /// <param name="created">Created date.</param>
 /// <param name="uniqueId">Unique identifier.</param>
 /// <param name="permissions">File action permissions.</param>
 /// <param name="language">File language.</param>
 /// <param name="mediaType">MIME file type.</param>
 /// <param name="characterSet">Character set of the file.</param>
 /// <param name="group">UNIX style group value.</param>
 /// <param name="owner">UNIX style owner value.</param>
 public FtpsMlsxItem(string name, 
                DateTime? modified, 
                long size, 
                FtpItemType itemType, 
                string attributes, 
                Int32? mode,
                string rawText,
                DateTime? created,
                string uniqueId,
                MlsxPerm permissions,
                string language,
                string mediaType,
                string characterSet,
                Int32? group,
                Int32? owner
              ) : base(name, modified, size, itemType, attributes, mode, String.Empty, rawText)
 {
     _created = created;
     _uniqueId = uniqueId;
     _permissions = permissions;
     _language = language;
     _mediaType = mediaType;
     _characterSet = characterSet;
     _group = group;
     _owner = owner;
 }
Exemplo n.º 14
0
        FtpItem ResolveAsUnix(string line)
        {
            Match m = _unixRegEx.Match(line);

            if (15 != m.Groups.Count)
            {
                return(null);
            }

            //looks like a UNIX style
            FtpItemType itemType = FtpItemType.Unresolved;
            string      name     = null;
            string      refName  = null;
            long        size     = 0;

            string strType = m.Groups["type"].Value;

            if (strType == "-")
            {
                itemType = FtpItemType.File;
            }
            else if (strType == "d")
            {
                itemType = FtpItemType.Directory;
            }
            else if (strType == "l")
            {
                itemType = FtpItemType.Link;
                refName  = m.Groups["link"].Value;
            }
            else
            {
                return(null);                //unknown
            }
            size = long.Parse(m.Groups["size"].Value);
            name = m.Groups["name"].Value;

            int    year    = 0;
            string strYear = m.Groups["year"].Value;

            if (strYear.Length > 0)
            {
                year = int.Parse(strYear);
            }
            else
            {
                year = DateTime.Now.Year;
            }

            int month = (int)_monthesHash[m.Groups["month"].Value];
            int day   = int.Parse(m.Groups["day"].Value);

            int    hour = 0, minutes = 0;
            string strHour = m.Groups["hour"].Value;

            if (strHour.Length > 0)
            {
                hour = int.Parse(strHour);
            }

            string strMinutes = m.Groups["min"].Value;

            if (strMinutes.Length > 0)
            {
                minutes = int.Parse(strMinutes);
            }

            DateTime dt = new DateTime(year, month, day, hour, minutes, 0, 0);

            return(new FtpItem(line, name, refName, dt, size, itemType));
        }
        private void ParseField(string field)
        {
            if (String.IsNullOrEmpty(field))
                throw new FtpsItemParsingException("field cannot be a null or empty value");

            if (field.IndexOf('=') == -1)
                throw new FtpsItemParsingException("field must contain equals '=' value");

            // split the field fact
            string[] fact = field.Split('=');

            if (fact.Length != 2)
                throw new FtpsItemParsingException("field must contain equals '=' value with only a name and value");

            string name = fact[0].Trim().ToLower();
            string value = fact[1].Trim();

            if (name.Length == 0)
                throw new FtpsItemParsingException("field fact name cannot be empty");

            switch (name)
            {
                case FACT_CHAR_SET:
                    _charSet = value;
                    break;
                case FACT_CREATE:
                    _create = ParseDateTime(value);
                    break;
                case FACT_LANG:
                    _lang = value;
                    break;
                case FACT_MEDIA_TYPE:
                    _mediaType = value;
                    break;
                case FACT_MODIFY:
                    _modified = ParseDateTime(value);
                    break;
                case FACT_PERM:
                    _perm = ParsePerm(value);
                    break;
                case FACT_SIZE:
                    _size = ParseSize(value);
                    break;
                case FACT_TYPE:
                    _itemType = ParseType(value);
                    break;
                case FACT_UNIQUE:
                    _unique = value;
                    break;
                case FACT_EXT_UNIX_GROUP:
                    _unixGroup = ParseInt32(value);
                    break;
                case FACT_EXT_UNIX_MODE:
                    _unixMode = ParseInt32(value);
                    if (_unixMode != null)
                        _attributes = FtpsUtilities.ModeToAttribute(_unixMode.Value);
                    break;
                case FACT_EXT_UNIX_OWNER:
                    _unixOwner = ParseInt32(value);
                    break;
                default:
                    break;
            }
        }
Exemplo n.º 16
0
        private FtpItem ParseUnixFormat(string line)
        {
            //System.Diagnostics.Debug.Assert(! (line == "-r-xr-xr-x   1 root     root        21969 Apr  8  1986 rfc982.txt"));


            string attribs  = _unixAttribs.Match(line).ToString();
            string month    = _unixMonth.Match(line).ToString();
            string day      = _unixDay.Match(line).ToString();
            string year     = _unixYear.Match(line).ToString();
            string time     = _unixTime.Match(line).ToString();
            string size     = _unixSize.Match(line).ToString();
            string name     = _unixName.Match(line).ToString().Trim();
            string symbLink = "";

            // ignore the microsoft 'etc' file that IIS uses for WWW users
            if (name == "~ftpsvc~.ckm")
            {
                return(null);
            }

            //  if we find a symbolic link then extract the symbolic link first and then
            //  extract the file name portion
            if (_unixSymbLink.IsMatch(name))
            {
                symbLink = _unixSymbLink.Match(name).ToString();
                name     = name.Substring(0, name.IndexOf("->")).Trim();
            }

            string itemType = _unixType.Match(line).ToString();


            //  if the current year is not given in unix then we need to figure it out.
            //  basically, if a date is within the past 6 months unix will show the
            //  time instead of the year
            if (year.Length == 0)
            {
                int curMonth = DateTime.Today.Month;
                int curYear  = DateTime.Today.Year;

                DateTime result;
                if (DateTime.TryParse(String.Format(CultureInfo.InvariantCulture, "1-{0}-2007", month), out result))
                {
                    if ((curMonth - result.Month) < 0)
                    {
                        year = Convert.ToString(curYear - 1, CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        year = curYear.ToString(CultureInfo.InvariantCulture);
                    }
                }
            }

            DateTime dateObj;

            DateTime.TryParse(String.Format(CultureInfo.InvariantCulture, "{0}-{1}-{2} {3}", day, month, year, time), out dateObj);

            long sizeLng = 0;

            Int64.TryParse(size, out sizeLng);

            FtpItemType itemTypeObj = FtpItemType.Unknown;

            switch (itemType.ToLower(CultureInfo.InvariantCulture))
            {
            case "l":
                itemTypeObj = FtpItemType.SymbolicLink;
                break;

            case "d":
                itemTypeObj = FtpItemType.Directory;
                break;

            case "-":
                itemTypeObj = FtpItemType.File;
                break;

            case "b":
                itemTypeObj = FtpItemType.BlockSpecialFile;
                break;

            case "c":
                itemTypeObj = FtpItemType.CharacterSpecialFile;
                break;

            case "p":
                itemTypeObj = FtpItemType.NamedSocket;
                break;

            case "s":
                itemTypeObj = FtpItemType.DomainSocket;
                break;
            }

            if (itemTypeObj == FtpItemType.Unknown || name.Trim().Length == 0)
            {
                return(null);
            }
            else
            {
                return(new FtpItem(name, dateObj, sizeLng, symbLink, attribs, itemTypeObj, line));
            }
        }
        /// <summary>
        /// Parse directory information
        /// </summary>
        /// <param name="baseUrl">The base URL</param>
        /// <param name="recordString">The record string.</param>
        /// <returns></returns>
        public FtpFile Parse(Uri baseUrl, string recordString)
        {
            // Instantiate the regular expression object.
            string attribs  = unixAttribs.Match(recordString).ToString();
            string month    = unixMonth.Match(recordString).ToString();
            string day      = unixDay.Match(recordString).ToString();
            string year     = unixYear.Match(recordString).ToString();
            string time     = unixTime.Match(recordString).ToString();
            string size     = unixSize.Match(recordString).ToString();
            string name     = unixName.Match(recordString).ToString().Trim();
            string symbLink = "";

            // ignore the microsoft 'etc' file that IIS uses for WWW users
            if (name == "~ftpsvc~.ckm")
            {
                return(null);
            }

            //  if we find a symbolic link then extract the symbolic link first and then
            //  extract the file name portion
            if (unixSymbLink.IsMatch(name))
            {
                symbLink = unixSymbLink.Match(name).ToString();
                name     = name.Substring(0, name.IndexOf("->")).Trim();
            }

            string itemType = unixType.Match(recordString).ToString();


            //  if the current year is not given in unix then we need to figure it out.
            //  basically, if a date is within the past 6 months unix will show the
            //  time instead of the year
            if (year.Length == 0)
            {
                int curMonth = DateTime.Today.Month;
                int curYear  = DateTime.Today.Year;

                DateTime result;
                if (DateTime.TryParse(String.Format(CultureInfo.InvariantCulture, "1-{0}-2007", month), out result))
                {
                    if ((curMonth - result.Month) < 0)
                    {
                        year = Convert.ToString(curYear - 1, CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        year = curYear.ToString(CultureInfo.InvariantCulture);
                    }
                }
            }

            DateTime dateObj;

            DateTime.TryParse(String.Format(CultureInfo.InvariantCulture, "{0}-{1}-{2} {3}", day, month, year, time), out dateObj);

            ulong sizeLng = 0;

            ulong.TryParse(size, out sizeLng);

            FtpItemType itemTypeObj = FtpItemType.Unknown;

            switch (itemType.ToLower(CultureInfo.InvariantCulture))
            {
            case "l":
                itemTypeObj = FtpItemType.SymbolicLink;
                break;

            case "d":
                itemTypeObj = FtpItemType.Directory;
                break;

            case "-":
                itemTypeObj = FtpItemType.File;
                break;

            case "b":
                itemTypeObj = FtpItemType.BlockSpecialFile;
                break;

            case "c":
                itemTypeObj = FtpItemType.CharacterSpecialFile;
                break;

            case "p":
                itemTypeObj = FtpItemType.NamedSocket;
                break;

            case "s":
                itemTypeObj = FtpItemType.DomainSocket;
                break;
            }

            if (itemTypeObj == FtpItemType.Unknown || name.Trim().Length == 0)
            {
                return(null);
            }
            else
            {
                return(new FtpFile(recordString, name, dateObj, sizeLng, symbLink, attribs, itemTypeObj, new Uri(baseUrl, name + ((itemTypeObj == FtpItemType.Directory) ? "/" : string.Empty))));
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// The FtpFile class represents the file and directory listing items as reported by the FTP server.
 /// </summary>
 /// <param name="originalRecordString">The original record string.</param>
 /// <param name="name">The name of the file/directory.</param>
 /// <param name="modifiedTime">Modified date and/or time of the item.</param>
 /// <param name="fileSize">Number of bytes or size of the item.</param>
 /// <param name="symbolicLink">Symbolic link name.</param>
 /// <param name="attributes">Permissions for the item</param>
 /// <param name="ftpItemType">The type of the item.</param>
 /// <param name="url">The url.</param>
 public FtpFile(string originalRecordString, string name, DateTime modifiedTime, ulong fileSize, string symbolicLink, string attributes, FtpItemType ftpItemType, Uri url)
 {
     this.OriginalRecordString = originalRecordString;
     this.Name         = name;
     this.ModifiedTime = modifiedTime;
     this.FileSize     = fileSize;
     this.SymbolicLink = symbolicLink;
     this.Attributes   = attributes;
     this.ItemType     = ftpItemType;
     this.Url          = url;
 }
        private void Parse(string line)
        {
            _rawText = line;

            // ex: Type=file;Size=1830;Modify=19940916055648;Perm=r; hatch.c
            // ex: modify=20120822211414;perm=adfr;size=2101;type=file;unique=16UF3F5;UNIX.group=49440;UNIX.mode=0744;UNIX.owner=49440; iphone_settings_icon.jpg
            // ex: modify=20030225143801;perm=adfr;size=503;type=file;unique=12U24470006;UNIX.group=0;UNIX.mode=0644;UNIX.owner=0; welcome.msg
            string[] fields = line.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            if (fields.Length == 0)
                return;

            // parse fact fields
            for (int i = 0; i < fields.Length - 1; i++)
            {
                ParseField(fields[i]);
            }

            // last field is always name of the object
            ParseName(fields[fields.Length - 1]);

            if (_name == ".")
                _itemType = FtpItemType.CurrentDirectory;
            if (_name == "..")
                _itemType = FtpItemType.ParentDirectory;
        }