var $exiftool = '/petabox/sw/books/exiftool/exiftool';
var $kduExpand = '/petabox/sw/bin/kdu_expand';
+ // Name of temporary files, to be cleaned at exit
+ var $tempFiles = array();
+
/*
* Serve an image request that requires looking up the book metadata
*
if ($this->passthruIfSuccessful($headers, $cmd, $errorMessage)) { // $$$ move to BookReaderRequest
$recovered = true;
} else {
+ $this->cleanup();
trigger_error('BookReader fallback image processing also failed: ' . $errorMessage, E_USER_WARNING);
}
}
}
}
- if (isset($tempFile)) {
- unlink($tempFile);
- }
+ $this->cleanup();
}
function getUnarchiveCommand($archivePath, $file)
// We use the BookReaderTiff prefix to give a hint in case things don't
// get cleaned up.
$tempFile = tempnam("/tmp", "BookReaderTiff");
+ array_push($this->tempFiles, $tempFile);
// $$$ look at bit depth when reducing
$decompressCmd =
}
function BRfatal($string) {
+ $this->cleanup();
throw new Exception("Image error: $string");
}
return $pageInfo;
}
+ // Clean up temporary files and resources
+ function cleanup() {
+ foreach($this->tempFiles as $tempFile) {
+ unlink($tempFile);
+ }
+ $this->tempFiles = array();
+ }
+
}
?>
\ No newline at end of file