Beispiel #1
0
        private static PhoneFileInfo ParseLsString(string strLine)
        {
            /*
            0:string permission;
            1:string node;
            2:string user;
            3:string group;
            4:string size;
            5:string day;
            6:string month;
            7:string date;
            8:string time;
            9:string year;
            10:string name;*/
            if (strLine == null || strLine.Length == 0)
                return null;
            PhoneFileInfo info = null;
            char[] chArray = strLine.ToCharArray();
            info = new PhoneFileInfo();
            string[] columns = new string[11];
            int start, end;
            bool lastIsSpace = false;
            start = 0;
            int i, col;
            for (col = 0, i = start; i < chArray.Length; i++)
            {
                if (col < 10)
                {
                    if (chArray[i] == ' ')
                    {

                        if (!lastIsSpace)
                        {
                            end = i;
                            columns[col] = strLine.Substring(start, end-start);
                            col++;
                        }
                        start = i+1;
                        lastIsSpace = true;
                    }
                    else
                    {
                        lastIsSpace = false;
                    }
                }
                else
                {
                    start = i;
                    break;
                }
            }
            if (col < 10)
                return null;
            columns[col] = strLine.Substring(start, strLine.Length-start);

            info.permission = columns[0];
            info.size = columns[4];
            info.modifyDate = columns[9] + " " + columns[6] + " " + columns[7];
            info.modifyTime = columns[8];
            if (columns[10].Substring(columns[10].Length - 1).Equals("/"))
            {
                info.isFile = false;
                if (columns[10].Contains("->"))
                {
                    string[] strs = SplitStr(columns[10], " -> ");//columns[10].Split(" -> ".ToCharArray());
                    info.isLink = true;
                    info.name = strs[0];
                    info.linkName = strs[1].Substring(0, strs[1].Length-1);
                }
                else
                    info.name = columns[10].Substring(0, columns[10].Length - 1);
            }
            else
            {
                info.isFile = true;
                if (columns[10].Contains("->"))
                {
                    string[] strs = SplitStr(columns[10], " -> ");// columns[10].Split(" -> ".ToCharArray());
                    info.isLink = true;
                    info.name = strs[0];
                    info.linkName = strs[1];
                }
                else
                    info.name = columns[10].Substring(0, columns[10].Length);
            }
            return info;
        }
Beispiel #2
0
        public static PhoneFileInfo GetFileInfo(string path)
        {
            PhoneFileInfo info = new PhoneFileInfo();

            return info;
        }