[cvs-annodex] commit (/annodex):
phpannodex/trunk/phpsrc/Classes/Annodex.php
ctford
nobody at lists.annodex.net
Wed Jan 4 15:55:19 EST 2006
Update of /annodex (new revision 1744)
Modified files:
phpannodex/trunk/phpsrc/Classes/Annodex.php
Log Message:
Now throws appropriate exceptions when constructed with invalid arguments.
Modified: phpannodex/trunk/phpsrc/Classes/Annodex.php
===================================================================
--- phpannodex/trunk/phpsrc/Classes/Annodex.php 2006-01-04 04:42:08 UTC (rev 1743)
+++ phpannodex/trunk/phpsrc/Classes/Annodex.php 2006-01-04 04:55:19 UTC (rev 1744)
@@ -1,15 +1,28 @@
<?php
+require_once("../Exceptions/FileNotFoundException.php");
+
abstract class Annodex {
const MIME_TYPE = "application/x-annodex";
+ const READ = ANX_READ;
+ const WRITE = ANX_WRITE;
private $anx_handle;
public function __construct( $type = ANX_WRITE, $filename = NULL ) {
+ if( $type != READ && $type != WRITE ) {
+ throw new Exception("Unknown Annodex type.");
+ }
+
if( $filename ) {
- $anx_handle = anx_open( $filename, $type );
+
+ if( $anx_handle = anx_open( $filename, $type ) ) {
+ return;
+ } else {
+ throw new FileNotFoundException("Couldn't open"
+ ." specified file.");
} else {
$anx_handle = anx_new( $type );
}
--
ctford
More information about the cvs-annodex
mailing list