Path

ez components / documentation / api reference / 1.1 / file


eZ Components 1.1

File

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Introduction

The File components currently contains one class that provides a few often used filesystem operations that are missing from PHP.

Class overview

This section gives you an overview on all classes, that are intended to be used directly.

ezcFile
The only class in this component. It only provides two static methods: ezcFile::findRecursive() and ezcFile::removeRecursive().

Usage

Finding Files Recursively

This example shows how to use the ezcFile::findRecursive() method:

  1. <?php
  2. require 'tutorial_autoload.php';
  3. 
  4. $data ezcFile::findRecursive(
  5.     "/dat/dev/ezcomponents",
  6.     array( '@src/.*_autoload.php$@' ),
  7.     array( '@/autoload/@' )
  8. );
  9. var_dump$data );
 10. 
 11. ?>

The code in this example searched for files in the /dat/dev/ezcomponents directory. It will only include files that match all patterns in the array that you passed as the $includeFilters parameter. Files that match any of the patterns in the array that you pass to $excludeFilters will not be returned either.

In other words the code above searches for files in the dat/dev/ezcomponents directory, that are in the src/ directory and end with _autoload.php. Except files that are in the /autoload/ directory.

Removing Directories Recursively

This example shows how to use the ezcFile::removeRecursive() method:

  1. <?php
  2. require 'tutorial_autoload.php';
  3. 
  4. ezcFile::removeRecursive'/dat/dev/ezcomponents/trash' );
  5. 
  6. ?>

This code simply removes the directory /dat/dev/ezcomponents/trash and all the files and directories in that directory.

Warning: Use this function with care, as it has the potential to erase everything that the current user has access to.

More Information

For more information, see the ezcFile API documentation.

Last updated: Wed, 28 Nov 2007