'Read from a VFS file and write to a GRRTempFile on disk.
If file writing doesn\'t complete files won\'t be cleaned up.
Args:
args: see CopyPathToFile in jobs.proto'

def Run(self, args):

    src_fd = vfs.VFSOpen(args.src_path, progress_callback=self.Progress)
    src_fd.Seek(args.offset)
    offset = src_fd.Tell()
    length = (args.length or (1024 ** 4))
    suffix = ('.gz' if args.gzip_output else '')
    (dest_fd, dest_pathspec) = tempfiles.CreateGRRTempFileVFS(directory=args.dest_dir, lifetime=args.lifetime, suffix=suffix)
    dest_file = dest_fd.name
    with dest_fd:
        if args.gzip_output:
            gzip_fd = gzip.GzipFile(dest_file, 'wb', 9, dest_fd)
            with gzip_fd:
                written = self._Copy(src_fd, gzip_fd, length)
        else:
            written = self._Copy(src_fd, dest_fd, length)
    self.SendReply(rdf_client.CopyPathToFileRequest(offset=offset, length=written, src_path=args.src_path, dest_dir=args.dest_dir, dest_path=dest_pathspec, gzip_output=args.gzip_output))
