Skip to content

Commit

Permalink
interface VersioncontrolItemExportDirectory
Browse files Browse the repository at this point in the history
it allow us to avoid the vc callback export_directory
  • Loading branch information
marvil07 committed Jul 28, 2009
1 parent 2319b08 commit 6c0504b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
21 changes: 9 additions & 12 deletions includes/VersioncontrolItem.php
Expand Up @@ -706,13 +706,8 @@ public function exportFile() {
* anymore.
*
* This function is optional for VCS backends to implement, be sure to check
* with versioncontrol_backend_implements($repository['vcs'], 'export_directory')
* if the particular backend actually implements it.
* return to NULL.
*
* @param $repository
* The repository that the directory item is located in.
* @param $directory_item
* The directory item whose contents should be exported.
* @param $destination_dirpath
* The path of the directory that will receive the contents of the exported
* repository item. If that directory already exists, it will be replaced.
Expand All @@ -727,19 +722,21 @@ public function exportFile() {
* or was not under version control at the time of the given revision,
* or simply cannot be exported to the destination directory for any reason.
*/
public function exportDirectory($repository, $directory_item, $destination_dirpath) {
if (!versioncontrol_is_directory_item($directory_item)) {
public function exportDirectory($destination_dirpath) {
if (!versioncontrol_is_directory_item($this)) {
return FALSE;
}
// Unless file.inc provides a nice function for recursively deleting
// directories, let's just go for the straightforward portable method.
$rm = (drupal_strtoupper(drupal_substr(PHP_OS, 0, 3)) == 'WIN') ? 'rd /s' : 'rm -rf';
exec("$rm $destination_dirpath");

$success = _versioncontrol_call_backend(
$repository['vcs'], 'export_directory',
array($repository, $directory_item, $destination_dirpath)
);
if ($this instanceof VersioncontrolItemExportDirectory) {
$success = $this->_exportDirectory($destination_dirpath);
}
else {
return FALSE;
}
if (!$success) {
exec("$rm $destination_dirpath");
return FALSE;
Expand Down
4 changes: 4 additions & 0 deletions includes/classes.inc
Expand Up @@ -184,3 +184,7 @@ interface VersioncontrolItemDirectoryContents {
interface VersioncontrolItemExportFile {
function _exportFile($destination);
}

interface VersioncontrolItemExportDirectory {
function _exportDirectory($destination_dirpath);
}

0 comments on commit 6c0504b

Please sign in to comment.