Gollem::_copyFile PHP Метод

_copyFile() защищенный статический Метод

Private function that copies/moves files.
protected static _copyFile ( $mode, $backend_f, $dir, $name, $backend_t, $newdir )
    protected static function _copyFile($mode, $backend_f, $dir, $name, $backend_t, $newdir)
    {
        $backend_key = $GLOBALS['session']->get('gollem', 'backend_key');
        $factory = $GLOBALS['injector']->getInstance('Gollem_Factory_Vfs');
        /* If the from/to backends are the same, we can just use the built-in
         * VFS functions. */
        if ($backend_f == $backend_t) {
            $ob = $factory->create($backend_f);
            try {
                if ($backend_f != $backend_key) {
                    $ob->checkCredentials();
                }
                if ($mode == 'copy') {
                    $ob->copy($dir, $name, $newdir);
                } else {
                    $ob->move($dir, $name, $newdir);
                }
            } catch (Horde_Vfs_Exception $e) {
                throw new Gollem_Exception($e);
            }
            return;
        }
        /* Else, get the two VFS objects and copy/move the files. */
        $from_be = $factory->create($backend_f);
        if ($backend_f != $backend_key) {
            try {
                $from_be->checkCredentials();
            } catch (Horde_Vfs_Exception $e) {
                throw new Gollem_Exception($e);
            }
        }
        $to_be = $factory->create($backend_t);
        if ($backend_t != $backend_key) {
            try {
                $to_be->checkCredentials();
            } catch (Horde_Vfs_Exception $e) {
                throw new Gollem_Exception($e);
            }
        }
        try {
            /* Read the source data. */
            $data = $from_be->read($dir, $name);
            /* Write the target data. */
            $to_be->writeData($newdir, $name, $data);
            /* If moving, delete the source data. */
            if ($mode == 'move') {
                $from_be->deleteFile($dir, $name);
            }
        } catch (Horde_Vfs_Exception $e) {
            throw new Gollem_Exception($e);
        }
    }