src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php
private function purgeRecursive( $dir, $limit, &$purgeCount )
    {
        $purgedIds = array();

        // Deal with files in the directory
        if ( ( $files = glob( "{$dir}*{$this->properties['options']->extension}" ) ) === false )
        {
            throw new ezcBaseFileNotFoundException(
                $dir,
                'cache location',
                'Produced an error while globbing for files.'
            );
        }

        foreach ( $files as $file )
        {
            if ( $this->calcLifetime( $file ) == 0 )
            {
                if ( @unlink( $file ) === false )
                {
                    throw new ezcBaseFilePermissionException(
                        $file,
                        ezcBaseFileException::WRITE,
                        'Could not unlink cache file.'
                    );
                }
                $fileInfo    = $this->extractIdentifier( $file );
                $purgedIds[] = $fileInfo['id'];
                ++$purgeCount;
            }
            // Stop purging if limit is reached
            if ( $limit !== null && $purgeCount >= $limit )
            {
                return $purgedIds;
            }
        }

        // Deal with sub dirs, this function expects them to be marked with a
        // slash because of the property $location
        if ( ( $dirs = glob( "$dir*", GLOB_ONLYDIR | GLOB_MARK ) ) === false )
        {
            throw new ezcBaseFileNotFoundException(
                $dir,
                'cache location',
                'Produced an error while globbing for directories.'
            );
        }
        foreach ( $dirs as $dir )
        {
            $purgedIds = array_merge(
                $purgedIds,
                $this->purgeRecursive( $dir, $limit, $purgeCount )
            );
            // Stop purging if limit is reached
            if ( $limit !== null && $purgeCount >= $limit )
            {
                return $purgedIds;
            }
        }

        // Finished purging, return IDs.
        return $purgedIds;
    }
private function purgeRecursive( $dir, $limit, &$purgeCount )
    {
        $purgedIds = array();

        // Deal with files in the directory
        if ( ( $files = glob( "{$dir}*{$this->properties['options']->extension}" ) ) === false )
        {
            throw new ezcBaseFileNotFoundException(
                $dir,
                'cache location',
                'Produced an error while globbing for files.'
            );
        }

        foreach ( $files as $file )
        {
            if ( $this->calcLifetime( $file ) == 0 )
            {
                if ( @unlink( $file ) === false )
                {
                    throw new ezcBaseFilePermissionException(
                        $file,
                        ezcBaseFileException::WRITE,
                        'Could not unlink cache file.'
                    );
                }
                $fileInfo    = $this->extractIdentifier( $file );
                $purgedIds[] = $fileInfo['id'];
                ++$purgeCount;
            }
            // Stop purging if limit is reached
            if ( $limit !== null && $purgeCount >= $limit )
            {
                return $purgedIds;
            }
        }

        // Deal with sub dirs, this function expects them to be marked with a
        // slash because of the property $location
        if ( ( $dirs = glob( "$dir*", GLOB_ONLYDIR | GLOB_MARK ) ) === false )
        {
            throw new ezcBaseFileNotFoundException(
                $dir,
                'cache location',
                'Produced an error while globbing for directories.'
            );
        }
        foreach ( $dirs as $dir )
        {
            $purgedIds = array_merge(
                $purgedIds,
                $this->purgeRecursive( $dir, $limit, $purgeCount )
            );
            // Stop purging if limit is reached
            if ( $limit !== null && $purgeCount >= $limit )
            {
                return $purgedIds;
            }
        }

        // Finished purging, return IDs.
        return $purgedIds;
    }
private function purgeRecursive ( $ dir , $ limit , & $ purgeCount ) { $ purgedIds = array ( ) ; // Deal with files in the directory if ( ( $ files = glob ( "{$dir}*{$this->properties['options']->extension}" ) ) === false ) { throw new ezcBaseFileNotFoundException ( $ dir , 'cache location' , 'Produced an error while globbing for files.' ) ; } foreach ( $ files as $ file ) { if ( $ this -> calcLifetime ( $ file ) == 0 ) { if ( @ unlink ( $ file ) === false ) { throw new ezcBaseFilePermissionException ( $ file , ezcBaseFileException :: WRITE , 'Could not unlink cache file.' ) ; } $ fileInfo = $ this -> extractIdentifier ( $ file ) ; $ purgedIds [ ] = $ fileInfo [ 'id' ] ; ++ $ purgeCount ; } // Stop purging if limit is reached if ( $ limit !== null && $ purgeCount >= $ limit ) { return $ purgedIds ; } } // Deal with sub dirs, this function expects them to be marked with a // slash because of the property $location if ( ( $ dirs = glob ( "$dir*" , GLOB_ONLYDIR | GLOB_MARK ) ) === false ) { throw new ezcBaseFileNotFoundException ( $ dir , 'cache location' , 'Produced an error while globbing for directories.' ) ; } foreach ( $ dirs as $ dir ) { $ purgedIds = array_merge ( $ purgedIds , $ this -> purgeRecursive ( $ dir , $ limit , $ purgeCount ) ) ; // Stop purging if limit is reached if ( $ limit !== null && $ purgeCount >= $ limit ) { return $ purgedIds ; } } // Finished purging, return IDs. return $ purgedIds ; }
Recursively purge cache items.

Recursively purges $dir until $limit is reached. $purgeCount is the
number of already purged items.

@param string $dir
@param int $limit
@param int $purgeCount
Recursively purge cache items .