/**
  * Return a path name where temporary files can be stored
  *
  * @return string
  *
  */
 public function getTempPath()
 {
     static $wtd = null;
     if (is_null($wtd)) {
         $wtd = new WireTempDir($this->className() . $this->page->id);
     }
     return $wtd->get();
 }
Exemple #2
0
/**
 * Return a new temporary directory/path ready to use for files
 * 
 * @param object|string $name Provide the object that needs the temp dir, or name your own string
 * @param array|int $options Options array: 
 * 	- maxAge: Maximum age of temp dir files in seconds (default=120)
 * 	- basePath: Base path where temp dirs should be created. Omit to use default (recommended).
 * 	Note: if you specify an integer for $options, then $maxAge is assumed. 
 * @return WireTempDir
 * 
 */
function wireTempDir($name, $options = array())
{
    static $tempDirs = array();
    if (isset($tempDirs[$name])) {
        return $tempDirs[$name];
    }
    if (is_int($options)) {
        $options = array('maxAge' => $options);
    }
    $basePath = isset($options['basePath']) ? $options['basePath'] : '';
    $tempDir = new WireTempDir($name, $basePath);
    if (isset($options['maxAge'])) {
        $tempDir->setMaxAge($options['maxAge']);
    }
    $tempDirs[$name] = $tempDir;
    return $tempDir;
}