Safe compilation (works in a temporary directory, on success then move it into env-production)

SVN:trunk[2835]
This commit is contained in:
Romain Quetiez
2013-08-27 12:19:55 +00:00
parent abae2129ad
commit e99d96e081
2 changed files with 95 additions and 17 deletions

View File

@@ -623,6 +623,44 @@ class SetupUtils
return false;
}
}
/**
* Helper to move a directory when the parent directory of the target dir cannot be written
* To be used as alternative to rename()
* Files/Subdirs of the source directory are moved one by one
* Returns void
*/
public static function movedir($sSource, $sDest)
{
if (!is_dir($sSource))
{
throw new Exception("movedir: the source directory '$sSource' is not a valid directory or cannot be read");
}
if (!is_dir($sDest))
{
self::builddir($sDest);
}
else
{
self::tidydir($sDest);
}
$aFiles = scandir($sSource);
if(sizeof($aFiles) > 0)
{
foreach($aFiles as $sFile)
{
if ($sFile == '.' || $sFile == '..')
{
// Skip
continue;
}
rename($sSource.'/'.$sFile, $sDest.'/'.$sFile);
}
}
rmdir($sSource);
}
static function GetPreviousInstance($sDir)
{
$bFound = false;