function saveBook($fileName, $baseDir = '.')
{
// Make fileName safe
// $fileName = self::sanitizeFileName($fileName); // It is up to the user to ensure valid file names.
// Finalize book, if it's not done already
if (!$this->isFinalized) {
$this->finalize();
}
if (!BinStringStatic::endsWith($fileName, ".epub")) {
$fileName .= ".epub";
}
// Try to open file access
$fh = fopen($baseDir . '/' . $fileName, "w");
if ($fh) {
fputs($fh, $this->getBook());
fclose($fh);
// if file is written return TRUE
return $fileName;
}
// return FALSE by default
return false;
}