# TempDirectory.class.php

Go to the documentation of this file.

    00001 <?php
    00002 /***************************************************************************
    00003  *   Copyright (C) 2007 by Ivan Y. Khvostishkov                            *
    00004  *                                                                         *
    00005  *   This program is free software; you can redistribute it and/or modify  *
    00006  *   it under the terms of the GNU Lesser General Public License as        *
    00007  *   published by the Free Software Foundation; either version 3 of the    *
    00008  *   License, or (at your option) any later version.                       *
    00009  *                                                                         *
    00010  ***************************************************************************/
    00011
    00012     final class TempDirectory
    00013     {
    00014         private $path = null;
    00015
    00016         public function __construct(
    00017             $directory = 'temp-garbage/', $prefix = 'TmpDir'
    00018         )
    00019         {
    00020             $this->path = FileUtils::makeTempDirectory($directory, $prefix);
    00021         }
    00022
    00023         public function __destruct()
    00024         {
    00025             try {
    00026                 FileUtils::removeDirectory($this->path, true);
    00027             } catch (BaseException $e) {
    00028                 // boo! deal with garbage yourself.
    00029             }
    00030         }
    00031
    00032         public function getPath()
    00033         {
    00034             return $this->path;
    00035         }
    00036     }
    00037 ?>