示例#1
0
        private static FileStruct ParseFileStructFromUnixStyleRecord(string record)
        {
            ///Assuming record style as
            /// dr-xr-xr-x   1 owner    group               0 Nov 25  2002 bussys
            FileStruct f = new FileStruct();

            if (record[0] == '-' || record[0] == 'd')
            {// its a valid file record
                string processstr = record.Trim();
                f.Flags       = processstr.Substring(0, 9);
                f.IsDirectory = (f.Flags[0] == 'd');
                processstr    = (processstr.Substring(11)).Trim();
                _cutSubstringFromStringWithTrim(ref processstr, ' ', 0);   //skip one part
                f.Owner      = _cutSubstringFromStringWithTrim(ref processstr, ' ', 0);
                f.CreateTime = getCreateTimeString(record);
                int fileNameIndex = record.IndexOf(f.CreateTime) + f.CreateTime.Length;
                f.Name = record.Substring(fileNameIndex).Trim();   //Rest of the part is name
            }
            else
            {
                f.Name = "";
            }
            return(f);
        }