3 class File_Convert_Solution
8 var $ext; // target extension
15 function __construct( $from ,$to)
21 require_once 'File/MimeType.php';
22 $mt = new File_MimeType();
23 $this->ext = $mt->toExt($this->to);
25 //$this->last = $this; //?? used where?
31 if (is_callable($this->debug)) {
32 call_user_func($this->debug,$str);
34 echo $str . "<br/>\n";
43 $this->debug("EXEC: $cmd");
45 $this->debug("RETURNED: $ret");
46 $this->cmd = $cmd ."\n" . $ret;
50 function count() // ??? why!?
56 require_once 'File/Convert/SolutionStack.php';
57 $ret = new File_Convert_SolutionStack();
63 $ret->list = array_merge($ret->list, $in->list);
69 function runconvert($fn, $x=0, $y=0, $pg=false)
71 if (!file_exists($fn)) {
72 $this->cmd = "ERROR:". $fn . " does not exist";
76 die("missing mimetype");
80 $this->debug("runconvert : {$fn}, {$x}, {$y}, {$pg}");
83 return $this->convert($fn, $x, $y, $pg);
86 function targetName($fn,$x,$y)
88 return $fn .'.'. $this->ext;
92 function convertExists($fn, $x, $y)
98 $fn = $this->targetName($fn, $x, $y);
100 return file_exists($fn) ? $fn : false;
104 function convert($fn,$x,$y,$pg) {
105 die("Convert not implemented for " . get_class($this));
110 static $deleteOnExit = false;
112 * generate a tempory file with an extension (dont forget to delete it)
115 function deleteOnExitAdd($name)
117 if (self::$deleteOnExit === false) {
118 self::$deleteOnExit = array();
119 register_shutdown_function(array('File_Convert_Solution','deleteOnExit'));
122 self::$deleteOnExit[] = $name;
125 function tempName($ext, $deleteOnExit=false)
128 $x = tempnam(ini_get('session.save_path'), HTML_FlexyFramework::get()->appNameShort.'TMP');
130 $ret = $x .'.'. $ext;
132 $this->deleteOnExitAdd($ret);
138 static function deleteOnExit()
140 if (count(func_get_args())) {
141 trigger_error("Call deleteOnExitAdd ?!?");
143 foreach(self::$deleteOnExit as $fn) {
144 if (file_exists($fn)) {
151 require_once 'System.php';
152 return System::which($n);