Beispiel #1
0
        /// <exception cref="System.IO.IOException"/>
        private long DumpFromOffset(PathData item, long offset)
        {
            long fileSize = item.RefreshStatus().GetLen();

            if (offset > fileSize)
            {
                return(fileSize);
            }
            // treat a negative offset as relative to end of the file, floor of 0
            if (offset < 0)
            {
                offset = Math.Max(fileSize + offset, 0);
            }
            FSDataInputStream @in = item.fs.Open(item.path);

            try
            {
                @in.Seek(offset);
                // use conf so the system configured io block size is used
                IOUtils.CopyBytes(@in, System.Console.Out, GetConf(), false);
                offset = @in.GetPos();
            }
            finally
            {
                @in.Close();
            }
            return(offset);
        }
        /// <exception cref="System.IO.IOException"/>
        protected internal override void RecursePath(PathData src)
        {
            PathData savedDst = dst;

            try
            {
                // modify dst as we descend to append the basename of the
                // current directory being processed
                dst = GetTargetPath(src);
                bool preserveRawXattrs = CheckPathsForReservedRaw(src.path, dst.path);
                if (dst.exists)
                {
                    if (!dst.stat.IsDirectory())
                    {
                        throw new PathIsNotDirectoryException(dst.ToString());
                    }
                }
                else
                {
                    if (!dst.fs.Mkdirs(dst.path))
                    {
                        // too bad we have no clue what failed
                        PathIOException e = new PathIOException(dst.ToString());
                        e.SetOperation("mkdir");
                        throw e;
                    }
                    dst.RefreshStatus();
                }
                // need to update stat to know it exists now
                base.RecursePath(src);
                if (dst.stat.IsDirectory())
                {
                    PreserveAttributes(src, dst, preserveRawXattrs);
                }
            }
            finally
            {
                dst = savedDst;
            }
        }