Ejemplo n.º 1
0
        public override Disk Execute(Disk disk, string param)
        {
            string path   = "";
            string addPar = "";

            CmdStrTool.SplitParam(param, addParam, out path, out addPar);
            if (string.IsNullOrEmpty(path))
            {
                CmdStrTool.ShowTips(1);
                return(null);
            }
            else
            {
                string[] paths = CmdStrTool.SplitPathParamToPathList(path);
                if (paths.Length != 2) //参数不对
                {
                    CmdStrTool.ShowTips(1);
                }
                else
                {
                    bool cover = addPar == "/y";
                    bool isRealFile = paths[0].First() == '@';
                    Node n1, n2;
                    //n1为拷贝前结点,真路径就创建一个
                    if (isRealFile)  //真实源路径,
                    {
                        string[] namelist1 = CmdStrTool.SplitPathToNameList(paths[0]);
                        string   newname   = namelist1.Last(); //最后一个是name
                        n1 = disk.CreateNode(0, newname, disk.root);
                        n1 = RealDiskTool.Instance.CopyRealFileToNode(paths[0].Substring(1), n1, disk);
                    }
                    else
                    {
                        string[] namelist1 = CmdStrTool.SplitPathToNameList(paths[0]);
                        n1 = disk.NameListToNode(namelist1, IsSupportWildcard);
                    }
                    //n2为目标目录,需要存在
                    string[] namelist2 = CmdStrTool.SplitPathToNameList(paths[1]);
                    n2 = disk.NameListToNode(namelist2, IsSupportWildcard);

                    if (n1 == null || n2 == null || n2.nodeType != 1)
                    {
                        CmdStrTool.ShowTips(2);
                    }
                    else
                    {
                        if (isRealFile)
                        {
                            disk.MoveNode(n1, n2, cover);
                        }
                        else
                        {
                            disk.CopyNode(n1, n2, cover);
                        }
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        public override Disk Execute(Disk disk, string param)
        {
            string path   = "";
            string addPar = "";

            CmdStrTool.SplitParam(param, addParam, out path, out addPar);
            if (string.IsNullOrEmpty(path))
            {
                CmdStrTool.ShowTips(1);
                return(null);
            }
            else
            {
                string[] paths = CmdStrTool.SplitPathParamToPathList(path);
                if (paths.Length != 2) //参数不对
                {
                    CmdStrTool.ShowTips(1);
                }
                else
                {
                    bool cover = addPar == "/y";
                    Node n1, n2;
                    //n1为移动前结点,需要存在
                    string[] namelist1 = CmdStrTool.SplitPathToNameList(paths[0]);
                    n1 = disk.NameListToNode(namelist1, IsSupportWildcard);

                    //n2为目标目录,需要存在
                    string[] namelist2 = CmdStrTool.SplitPathToNameList(paths[1]);
                    n2 = disk.NameListToNode(namelist2, IsSupportWildcard);

                    if (n1 == null || n2 == null || n2.nodeType != 1)
                    {
                        CmdStrTool.ShowTips(2);
                    }
                    else
                    {
                        disk.MoveNode(n1, n2, cover);
                        Console.WriteLine("移动:{0}--->{1}", n1.name, n2.GetPath());
                    }
                }
            }
            return(null);
        }