Example #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();
            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.Group = CutSubstringFromStringWithTrim(ref processstr, ' ', 0);
            CutSubstringFromStringWithTrim(ref processstr, ' ', 0);   //skip one part

            string cutSubstringForCreateTime =
                CutSubstringFromStringWithTrim(ref processstr, ' ', 8);

            int    indexOfSpace = cutSubstringForCreateTime.IndexOf(' ');
            string month        = cutSubstringForCreateTime.Substring(0, indexOfSpace + 1);

            if (cutSubstringForCreateTime[month.Length] == ' ')
            {
                month += " ";
            }

            int day = FlatRedBall.Utilities.StringFunctions.GetIntAfter(month, cutSubstringForCreateTime);

            string rearranged = day + " " + cutSubstringForCreateTime.Replace(day + " ", "");

            int lastSpace = rearranged.LastIndexOf(' ');

            string modifiedRearranged = rearranged.Substring(0, lastSpace);

            if (!DateTime.TryParse(modifiedRearranged, out f.CreateTime))
            {
                f.CreateTime = new DateTime();
            }

            f.Name = processstr;   //Rest of the part is name
            return(f);
        }