function ConvertSchemaFile($filename, $newVersion = NULL, $newFile = NULL)
{
// grab current version
if (!($version = $this->SchemaFileVersion($filename))) {
return FALSE;
}
if (!isset($newVersion)) {
$newVersion = $this->schemaVersion;
}
if ($version == $newVersion) {
$result = _file_get_contents($filename);
// remove unicode BOM if present
if (substr($result, 0, 3) == sprintf('%c%c%c', 239, 187, 191)) {
$result = substr($result, 3);
}
} else {
$result = $this->TransformSchema($filename, 'convert-' . $version . '-' . $newVersion, 'file');
}
if (is_string($result) and is_string($newFile) and $fp = fopen($newFile, 'w')) {
fwrite($fp, $result);
fclose($fp);
}
return $result;
}