VFS
[ class tree: VFS ] [ index: VFS ] [ all elements ]

Source for file GC.php

Documentation is available at GC.php

  1. <?php
  2. /**
  3.  * Class for providing garbage collection for any VFS instance.
  4.  *
  5.  * $Horde: framework/VFS/lib/VFS/GC.php,v 1.1.2.3 2009/01/06 15:23:47 jan Exp $
  6.  *
  7.  * Copyright 2003-2009 The Horde Project (http://www.horde.org/)
  8.  *
  9.  * See the enclosed file COPYING for license information (LGPL). If you
  10.  * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  11.  *
  12.  * @author  Michael Slusarz <slusarz@horde.org>
  13.  * @package VFS
  14.  */
  15. class VFS_GC {
  16.  
  17.     /**
  18.      * Garbage collect files in the VFS storage system.
  19.      *
  20.      * @param VFS &$vfs      The VFS object to perform garbage collection on.
  21.      * @param string $path   The VFS path to clean.
  22.      * @param integer $secs  The minimum amount of time (in seconds) required
  23.      *                        before a file is removed.
  24.      */
  25.     function gc(&$vfs$path$secs = 345600)
  26.     {
  27.         /* A 1% chance we will run garbage collection during a call. */
  28.         if (rand(099!= 0{
  29.             return;
  30.         }
  31.  
  32.         /* Use a backend-specific method if one exists. */
  33.         if (is_callable(array($vfs'gc'))) {
  34.             return $vfs->gc($path$secs);
  35.         }
  36.  
  37.         /* Make sure cleaning is done recursively. */
  38.         $files $vfs->listFolder($pathnulltruefalsetrue);
  39.         if (!is_a($files'PEAR_Error'&& is_array($files)) {
  40.             $modtime time($secs;
  41.             foreach ($files as $val{
  42.                 if ($val['date'$modtime{
  43.                     $vfs->deleteFile($path$val['name']);
  44.                 }
  45.             }
  46.         }
  47.     }
  48.  
  49. }

Documentation generated on Mon, 11 Mar 2019 15:34:54 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.