[ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 3 /** 4 * Strategy for writing file to temporary directory, then copying to VFS. 5 * 6 * $Horde: framework/VFS_ISOWriter/ISOWriter/RealOutputStrategy/copy.php,v 1.1.8.4 2006/01/01 21:28:44 jan Exp $ 7 * 8 * Copyright 2004-2006 Cronosys, LLC <http://www.cronosys.com/> 9 * 10 * See the enclosed file COPYING for license information (LGPL). If you 11 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 12 * 13 * @author Jason M. Felice <jfelice@cronosys.com> 14 * @package VFS_ISO 15 * @since Horde 3.0 16 */ 17 class VFS_ISOWriter_RealOutputStrategy_copy extends VFS_ISOWriter_RealOutputStrategy { 18 19 var $_tempFilename = null; 20 21 /** 22 * Get a real filename to which we can write. 23 * 24 * In this implementation, we create and store a temporary filename. 25 */ 26 function getRealFilename() 27 { 28 if (is_null($this->_tempFilename)) { 29 30 $tmp_locations = array('/tmp', '/var/tmp', 'c:\WUTemp', 'c:\temp', 31 'c:\windows\temp', 'c:\winnt\temp'); 32 33 /* First, try PHP's upload_tmp_dir directive. */ 34 $tmp = ini_get('upload_tmp_dir'); 35 36 /* Otherwise, try to determine the TMPDIR environment 37 * variable. */ 38 if (empty($tmp)) { 39 $tmp = getenv('TMPDIR'); 40 } 41 42 /* If we still cannot determine a value, then cycle through a 43 * list of preset possibilities. */ 44 while (empty($tmp) && count($tmp_locations)) { 45 $tmp_check = array_shift($tmp_locations); 46 if (@is_dir($tmp_check)) { 47 $tmp = $tmp_check; 48 } 49 } 50 51 if (empty($tmp)) { 52 return PEAR::raiseError(_("Cannot find a temporary directory.")); 53 } 54 55 $this->_tempFilename = tempnam($tmp, 'iso'); 56 } 57 58 return $this->_tempFilename; 59 } 60 61 function finished() 62 { 63 if (empty($this->_tempFilename)) { 64 return; 65 } 66 if (!file_exists($this->_tempFilename)) { 67 return; 68 } 69 70 if (preg_match('!^(.*)/([^/]*)$!', $this->_targetFile, $matches)) { 71 $dir = $matches[1]; 72 $file = $matches[2]; 73 } else { 74 $dir = ''; 75 $file = $this->_targetFile; 76 } 77 78 $res = $this->_targetVfs->write($dir, $file, $this->_tempFilename, 79 true); 80 @unlink($this->_tempFilename); 81 $this->_tempFilename = null; 82 return $res; 83 } 84 85 } 86
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |