Пример #1
0
        public void Process(CopyItem[] copyItems)
        {
            copier.SetWipDir(wipDir);
            copier.SetCopyArg(copyArgs);
            copier.SetCopyCmd(copyCmds);

            Utils.CopyDirectory(srcDir, wipDir);

            foreach (CopyItem ci in copyItems)
            {
                (CopyType ct, string cmd, string args) = copier.GetCpCommand(ci);

                string srcPath = ci.From;
                if (ct.Equals(CopyType.Cp))
                {
                    srcPath = String.Format("{0}/{1}", srcDir, ci.From);
                }

                string dstPath = copier.GetDestPath(ci, ct);

                if (ct.Equals(CopyType.Cp))
                {
                    Utils.CopyFile(srcPath, dstPath);
                }
                else
                {
                    string argv = String.Format("{0} {1} {2}", args, srcPath, dstPath);
                    Utils.Exec(cmd, argv);
                }
            }
        }
Пример #2
0
        public void GetCpCommandTest(string from, CopyType expType, string expArgs)
        {
            var cp = new UtilCopier();

            cp.SetCopyArg(copyArgs);
            cp.SetCopyCmd(copyCmds);
            cp.SetWipDir("");

            var ci = new CopyItem();

            ci.From = from;

            (CopyType type, string cmd, string args) = cp.GetCpCommand(ci);

            Assert.AreEqual(expType, type);
            Assert.AreEqual(expArgs, args);
        }