'Copy file, or directory, in HDFS to another location in HDFS.
``src`` -- The directory, or file, to copy from.
``dest`` -- the directory, or file, to copy to.
If \'dest\' is a directory that exists, copy \'src\' into dest.
If \'dest\' is a file that exists and \'src\' is a file, overwrite dest.
If \'dest\' does not exist, create \'src\' as \'dest\'.
``recursive`` -- Recursively copy contents of \'src\' to \'dest\'.
This is required for directories.
``dir_mode`` and ``owner`` are used to define permissions on the newly
copied files and directories.
This method will overwrite any pre-existing files that collide with what is being copied.
Copying a directory to a file is not allowed.'

def copy(self, src, dest, recursive=False, dir_mode=None, owner=None):

    if (owner is None):
        owner = self.user
    if (dir_mode is None):
        sb = self._stats(src)
        dir_mode = oct(stat.S_IMODE(sb.mode))
    src = self.abspath(src)
    dest = self.abspath(dest)
    if (not self.exists(src)):
        raise IOError(errno.ENOENT, (_('File    not    found:    %s') % src))
    if self.isdir(src):
        if (not recursive):
            LOG.debug(('Skipping    contents    of    %s' % src))
            return None
        if self.exists(dest):
            if self.isdir(dest):
                dest = self.join(dest, self.basename(src))
            else:
                raise IOError(errno.EEXIST, (_('Destination    file    %s    exists    and    is    not    a    directory.') % dest))
        self.do_as_user(owner, self.mkdir, dest, mode=dir_mode)
        self.copy_remote_dir(src, dest, dir_mode, owner)
    elif (self.exists(dest) and self.isdir(dest)):
        self.copyfile(src, self.join(dest, self.basename(src)))
    else:
        self.copyfile(src, dest)
