Example #1
0
        /// <summary>
        /// 从Unix格式中返回文件信息
        /// </summary>
        /// <param name="record">文件信息</param>
        public FileStruct ParseFileStructFromUnixStyle(string record)
        {
            FileStruct f          = new FileStruct();
            string     processstr = record.Trim();

            f.Flags       = processstr.Substring(0, 10);
            f.IsDirectory = (f.Flags[0] == 'd');
            processstr    = (processstr.Substring(11)).Trim();

            CutStringByRule(ref processstr, ' ', 0);   //跳过一部分
            f.Owner = CutStringByRule(ref processstr, ' ', 0);
            f.Group = CutStringByRule(ref processstr, ' ', 0);
            CutStringByRule(ref processstr, ' ', 0);   //跳过一部分

            string yearOrTime = processstr.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[2];

            if (yearOrTime.IndexOf(":") >= 0)  //time
            {
                processstr = processstr.Replace(yearOrTime, DateTime.Now.Year.ToString());
            }
            f.CreateTime = DateTime.Parse(CutStringByRule(ref processstr, ' ', 8));
            f.Name       = processstr; //最后就是名称
            return(f);
        }