public function copyDefinitions($SourcePath, $DestPath)
{
// Load the definitions from the source path.
$Definitions = $this->loadDefinitions($SourcePath);
$TmpPath = dirname($DestPath) . '/tmp_' . randomString(10);
$Key = trim(strchr($SourcePath, '/'), '/');
$fp = fopen($TmpPath, 'wb');
if (!$fp) {
throw new Exception(sprintf(t('Could not open %s.'), $TmpPath));
}
fwrite($fp, $this->getFileHeader());
fwrite($fp, "/** Definitions copied from {$Key}. **/\n\n");
$this->writeDefinitions($fp, $Definitions);
fclose($fp);
$Result = rename($TmpPath, $DestPath);
if (!$Result) {
throw new Exception(sprintf(t('Could not open %s.'), $DestPath));
}
return $DestPath;
}