Ejemplo n.º 1
0
        public virtual Status CheckPath(ref MString path, out Component targetDir, out MString fileName, bool usePattern)
        {
            targetDir = null;
            fileName  = "*";
            path      = path.Replace("\"", "").MultiReplace("\\", "\\");
            MString[] paths = path.MultiSplit('\\');

            MString rootName = paths[0];
            bool    isEnding = paths.Length < 2;
            Status  status   = CheckRootPath(ref targetDir, ref fileName, rootName, usePattern, isEnding);

            if (status != Status.Succeed || isEnding)
            {
                return(status);
            }

            for (int i = 1; i < paths.Length - 1; i++)
            {
                if (paths[i].Trim() == "")
                {
                    return(Status.Error_Path_Format);
                }

                if (nameRegex.IsMatch(paths[i]))
                {
                    return(Status.Error_Path_Format);
                }

                if (paths[i] == ".")
                {
                    continue;
                }
                else if (paths[i] == "..")
                {
                    if (targetDir.parent != null)
                    {
                        targetDir = targetDir.parent;
                    }

                    continue;
                }

                status = EnterDirectory(ref targetDir, paths[i]);
                if (status != Status.Succeed)
                {
                    return(status);
                }
            }


            string endName = paths[paths.Length - 1];

            return(CheckEndPath(ref targetDir, ref fileName, endName, usePattern));
        }
Ejemplo n.º 2
0
        public static void Test()
        {
            MString str1 = null;
            MString str2 = "def";
            MString str3 = "def";

            Console.WriteLine(str1 + str2);
            if (str2 == null)
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }


            if (str1 == null)
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }


            if (str1 == str3)
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }


            if (str1 == "")
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }


            if (str3 == "")
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }


            if (str3 == str2)
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }
            str3 = str1 + str2;

            if (str3 == str2)
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }

            str3.Replace("e", "");

            if (str3 == str2)
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }

            Console.ReadLine();
        }