Exemplo n.º 1
0
        /// Execute action
        public override object Execute()
        {
            DirectoryInfo d = new DirectoryInfo(Context.TransformStr(To, Transform));

            d.Create();
            if (Clean)
            {
                Delete del = new Delete {
                    From = d.ToString(), Recursive = true, ReadOnly = true
                };
                Context.Execute(del);
            }

            var zip = Context.Transform(From, Transform);


            var nf = new FileNameOnlyFilter(Syntax, Context.TransformStr(Filter, Transform));
            var df = new StringFilter(Syntax, Context.TransformStr(DirectoryFilter, Transform));

            var ret = extractZip(zip, d.FullName, nf, df);

            if (ReturnValue.IsBreak(ret))
            {
                return(null);
            }
            ReturnValue.RethrowIfException(ret);
            return(ret);
        }
Exemplo n.º 2
0
        /// Execute action
        public override object Execute()
        {
            string fromExpanded = Context.TransformStr(From, Transform);
            string toExpanded   = Context.TransformStr(To, Transform);

            var nf = new FileNameOnlyFilter(Syntax, Context.TransformStr(Filter, Transform));
            var df = new FullPathFilter(Syntax, Context.TransformStr(DirectoryFilter, Transform), BackslashOption.Add);

            object ret = null;
            Uri    uri;

            if (Uri.TryCreate(fromExpanded, UriKind.Absolute, out uri))
            {
                if (uri.IsFile)
                {
                    fromExpanded = uri.LocalPath;
                    uri          = null;
                }
            }

            if (uri != null)
            {
                FileInfo to;
                toExpanded = Download.UrlToLocalFileName(fromExpanded, toExpanded);
                to         = new FileInfo(toExpanded);
                VerboseMessage("Copying from URI {0} to {1}", fromExpanded, to);
                ret = downloadSingleFile(nf, uri, to);
            }
            else
            {
                DirectoryInfo di = new DirectoryInfo(fromExpanded);
                if (fromExpanded.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal) ||
                    fromExpanded.EndsWith(Path.AltDirectorySeparatorChar.ToString(), StringComparison.Ordinal) ||
                    di.Exists)
                {
                    VerboseMessage("Copying a directory {0} to {1}", di, toExpanded);
                    ret = copy(di, di, new DirectoryInfo(toExpanded), nf, df);
                }
                else
                {
                    FileInfo fr = new FileInfo(fromExpanded);
                    FileInfo to;
                    if (toExpanded.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal) ||
                        toExpanded.EndsWith(Path.AltDirectorySeparatorChar.ToString(), StringComparison.Ordinal) ||
                        new DirectoryInfo(toExpanded).Exists)
                    {
                        to = new FileInfo(Path.Combine(new DirectoryInfo(toExpanded).FullName, fr.Name));
                    }
                    else
                    {
                        to = new FileInfo(toExpanded);
                    }
                    VerboseMessage("Copying a single file {0} to {1}", fr, to);
                    ret = copySingleFile(nf, fr, to);
                }
            }
            if (ReturnValue.IsBreak(ret))
            {
                return(null);
            }
            ReturnValue.RethrowIfException(ret);
            return(ret);
        }
Exemplo n.º 3
0
        /// Execute action
        public override object Execute()
        {
            string fromExpanded = Context.TransformStr(From, Transform);
            string toExpanded = Context.TransformStr(To, Transform);

            var nf = new FileNameOnlyFilter(Syntax, Context.TransformStr(Filter, Transform));
            var df = new FullPathFilter(Syntax, Context.TransformStr(DirectoryFilter, Transform), BackslashOption.Add);

            object ret = null;
            Uri uri;
            if (Uri.TryCreate(fromExpanded, UriKind.Absolute, out uri))
                if (uri.IsFile)
                {
                    fromExpanded=uri.LocalPath;
                    uri=null;
                }

            if (uri!=null)
            {
                FileInfo to;
                toExpanded= Download.UrlToLocalFileName(fromExpanded,toExpanded);
                to = new FileInfo(toExpanded);
                VerboseMessage("Copying from URI {0} to {1}", fromExpanded, to);
                ret=downloadSingleFile(nf,uri,to);
            }
            else
            {
                DirectoryInfo di = new DirectoryInfo(fromExpanded);
                if (fromExpanded.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal) ||
                    fromExpanded.EndsWith(Path.AltDirectorySeparatorChar.ToString(), StringComparison.Ordinal) ||
                    di.Exists)
                {
                    VerboseMessage("Copying a directory {0} to {1}", di, toExpanded);
                    ret = copy(di, di, new DirectoryInfo(toExpanded), nf, df);
                }
                else
                {

                    FileInfo fr = new FileInfo(fromExpanded);
                    FileInfo to;
                    if (toExpanded.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal) ||
                        toExpanded.EndsWith(Path.AltDirectorySeparatorChar.ToString(), StringComparison.Ordinal) ||
                        new DirectoryInfo(toExpanded).Exists)
                    {
                        to = new FileInfo(Path.Combine(new DirectoryInfo(toExpanded).FullName, fr.Name));
                    }
                    else
                    {
                        to = new FileInfo(toExpanded);
                    }
                    VerboseMessage("Copying a single file {0} to {1}", fr, to);
                    ret = copySingleFile(nf, fr, to);
                }
            }
            if (ReturnValue.IsBreak(ret))
                return null;
            ReturnValue.RethrowIfException(ret);
            return ret;
        }
Exemplo n.º 4
0
        /// Execute action
        public override object Execute()
        {
            DirectoryInfo d = new DirectoryInfo(Context.TransformStr(To, Transform));
            d.Create();
            if (Clean)
            {
                Delete del = new Delete { From = d.ToString(), Recursive = true, ReadOnly = true };
                Context.Execute(del);
            }

            var zip = Context.Transform(From, Transform);

            var nf = new FileNameOnlyFilter(Syntax, Context.TransformStr(Filter,Transform));
            var df = new StringFilter(Syntax, Context.TransformStr(DirectoryFilter,Transform));

            var ret=extractZip(zip, d.FullName, nf, df);
            if (ReturnValue.IsBreak(ret))
                return null;
            ReturnValue.RethrowIfException(ret);
            return ret;
        }