private static ItemPrivileges specifyItemPrivileges(ref List <String> _attributes) { ItemPrivileges itemPrivileges = new ItemPrivileges(); DateTime dateTime; if (_attributes.Count == 0) { return(itemPrivileges); } // if no privileges are setted if (DateTime.TryParse(_attributes[0], out dateTime)) { return(itemPrivileges); } else { itemPrivileges = ItemPrivileges.GetItemPrivileges(_attributes[0]); } return(itemPrivileges); }
public static ItemPrivileges GetItemPrivileges(String _privileges) { ItemPrivileges itemPrivileges = new ItemPrivileges(); itemPrivileges.USER_NAME = ItemPrivilege.GetItemPrivilege(_privileges.Substring(0, 3)); itemPrivileges.Group = ItemPrivilege.GetItemPrivilege(_privileges.Substring(3, 3)); itemPrivileges.Others = ItemPrivilege.GetItemPrivilege(_privileges.Substring(6, 3)); return itemPrivileges; }
public static ItemPrivileges GetItemPrivileges(String _privileges) { ItemPrivileges itemPrivileges = new ItemPrivileges(); itemPrivileges.USER_NAME = ItemPrivilege.GetItemPrivilege(_privileges.Substring(0, 3)); itemPrivileges.Group = ItemPrivilege.GetItemPrivilege(_privileges.Substring(3, 3)); itemPrivileges.Others = ItemPrivilege.GetItemPrivilege(_privileges.Substring(6, 3)); return(itemPrivileges); }
public static FTPItem GetFTPItem(String _item, params Char[] _delimiter) { List <String> attributes = new List <String>(); FTPItem ftpItem = new FTPItem(); // split items foreach (String attribute in _item.Split(_delimiter)) { if (attribute.Length != 0) { attributes.Add(attribute); } } DateTime dateTime; String dateTimeString = String.Empty; // if the ftpItem starts with modified Date ( Microsoft IIS Format ) if (attributes[0].Contains('-') && !(attributes[0].Contains('r') || attributes[0].Contains('w') || attributes[0].Contains('x'))) { try { List <String> dateTimeParts = attributes[0].Insert(attributes[0].LastIndexOf('-') + 1, "20").Split('-').ToList(); dateTimeString = String.Format("{0}.{1}.{2}", dateTimeParts[1], dateTimeParts[0], dateTimeParts[2]); } catch {}; } if (DateTime.TryParse(dateTimeString, out dateTime)) { Int32 size; String datetime = String.Format("{0} {1}", dateTimeString, attributes[1]); DateTime dateModified; if (DateTime.TryParse(datetime, out dateModified)) { ftpItem.dateModified = dateModified; } if (attributes[2].Equals("<DIR>")) { ftpItem.isDirectory = true; ftpItem.name = attributes[3]; } else { if (Int32.TryParse(attributes[2], out size)) { ftpItem.size = size; } ftpItem.name = attributes[3]; } } else { if (_item[0] == 'd' || _item[0] == 'l') { ftpItem.isDirectory = true; } else { ftpItem.isDirectory = false; } _item = _item.Remove(0, 1); String dateTimeFormatString = String.Empty; if (attributes[(Int32)Attribute.DateModified_TimeOrYear].Contains(':')) { dateTimeFormatString = "{0}.{1}.2011 {2}:00"; } else { dateTimeFormatString = "{0}.{1}.{2}"; } String dateModified = String.Format(dateTimeFormatString, attributes[(Int32)Attribute.DateModified_Day], attributes[(Int32)Attribute.DateModified_Month], attributes[(Int32)Attribute.DateModified_TimeOrYear] ); ftpItem.itemPrivileges = ItemPrivileges.GetItemPrivileges(attributes[(Int32)Attribute.ItemPrivileges]); ftpItem.node = Int32.Parse(attributes[(Int32)Attribute.Node]); ftpItem.user = attributes[(Int32)Attribute.USER_NAME]; ftpItem.group = attributes[(Int32)Attribute.Group]; ftpItem.size = Int32.Parse(attributes[(Int32)Attribute.Size]); ftpItem.dateModified = DateTime.Parse(dateModified); ftpItem.name = attributes[(Int32)Attribute.Name]; for (Int32 i = (Int32)Attribute.Name + 1; i < attributes.Count; i++) { ftpItem.name = String.Format("{0} {1}", ftpItem.name, attributes[i]); } } return(ftpItem); }
private static ItemPrivileges specifyItemPrivileges(ref List<String> _attributes) { ItemPrivileges itemPrivileges = new ItemPrivileges(); DateTime dateTime; if (_attributes.Count == 0) return itemPrivileges; // if no privileges are setted if (DateTime.TryParse(_attributes[0], out dateTime)) return itemPrivileges; else { itemPrivileges = ItemPrivileges.GetItemPrivileges(_attributes[0]); } return itemPrivileges; }