>> YANA 4 PHP Framework >> Docs For Class DirStream

Class DirStream

Description

Manipulate a directory

This class represents a directory. You may use this to get a list of contents, or remove, or create a directory.

  • access: public

Located in /includes/class_dirstream.php

Object
   |
   --InputStream
      |
      --DirStream
Method Summary
  • DirStream DirStream (string $path)
  • bool create ([int $mode = 777])
  • bool delete ([bool $is_recursive = false])
  • array dirlist (string $filter)
  • bool exists ()
  • array get ()
  • int|bool(false) getSize ([string $directory = null], [bool $includeSubDirs = true], [bool $useCache = true])
  • bool isEmpty ()
  • int length ()
  • bool read ()
  • string toString ()

Methods

constructor
DirStream DirStream (
string $path
)
List of parameters:
Name Type Description
$path string
Description:

Create a new instance of this class.

create this directory
bool create (
[int $mode = 777]
)
List of parameters:
Name Type Description
$mode int access mode
Description:

Tries to create the directory. Check the developer's cookbook for an example to this function.

  • name: DirStream::create()
  • access: public
  • uses: $DirStream->create(660)
remove this directory
bool delete (
[bool $is_recursive = false]
)
List of parameters:
Name Type Description
$is_recursive bool triggers wether to remove directories even if they are not empty, default = false
Description:

By option you may choose to also recursivly remove all files and subdirectories inside. Otherwise the directory will only be removed if it is empty.

Returns bool(true) on success and bool(false) on error.

  • access: public
  • uses: $DirStream->delete(false)
list contents of a directory
array dirlist (
string $filter
)
List of parameters:
Name Type Description
$filter string
Description:

The argument $filter may contain multiple file extension, use a pipe '|' sign to seperate them. Example: "*.xml|*.html" will find all xml- and html-files

  • access: public
  • uses: $DirStream->dirlist('*.cfg')
check if directory exists and is readable
bool exists ()
Description:

Returns bool(true) on success and bool(false) otherwise.

  • access: public

Redefinition of: InputStream::exists()

return list of files within the directory
array get ()
Description:

NOTE: will only return filenames with the path stripped

  • access: public
  • uses: $DirStream->get()

Redefinition of: InputStream::get()

get size of directory
int|bool(false) getSize (
[string $directory = null], [bool $includeSubDirs = true], [bool $useCache = true]
)
List of parameters:
Name Type Description
$directory string directory name
$includeSubDirs bool on / off
$useCache bool on / off
Description:

Returns the size of $directory in bytes.

This function gets the sum of the sizes of all files in a directory.

If $directory is not provided or NULL, the current directory is used. If $includeSubDirs is not provided or true, the result will include all subdirectories.

If $useCache is not provided or true, the result is cached for the current directory.

Returns bool(false) if the directory does not exist and issues an E_USER_WARNING.

  • since: 2.8.8
  • access: public
  • uses: $DirStream->getSize()
  • uses: $DirStream->getSize('foo/bar')
check wether the directory has no contents
bool isEmpty ()
Description:

Returns bool(true) if there are no files that match the current filter and bool(false) if there is at least 1 file that matches.

  • access: public
  • uses: $DirStream->isEmpty()
get the number of files inside the directory
int length ()
Description:

This returns a positive integer. Note that this functions counts the files in respect to the currently set file filter. So the number of files reported here and the number in total may vary.

  • access: public
  • uses: $DirStream->length()
read contents and put results in cache (filter settings will be applied)
bool read ()
Description:
  • access: public
  • uses: $DirStream->read()
return a string representation of this directory
string toString ()
Description:

Returns a string with the contents of this directory. Entries are seperated by line-breaks.

  • access: public
  • uses: $DirStream->toString()

Redefinition of: Object::toString()

inherited from base classes

Inherited From InputStream

Inherited From Object

Documentation generated on Sun, 11 Mar 2007 15:02:28 +0100 by phpDocumentor 1.3.1

yana author: Thomas MeyerHomepage: www.yanaframework.net