File/common/pcf_directory.phpinc

Description

Common Directory Functions

  • author: Peter Krebs (pk)<p.krebs@lvus.at>
  • version: $Id: pcf_directory.phpinc,v 1.11 2008/11/06 08:41:58 pitlinz Exp $
  • copyright: (c) 2002-2003 by Peter Krebs and Landesverlag Unternehmensservice
  • project: Open CSP-Management
  • filesource: Source Code for this file
  • license: GNU Public License
Includes
 require (__OCSP_PHPINCPATH__."common"._OCSP_DIRSEP_."pcf_file.phpinc") (line 18)
Functions
pcf_checkDir (line 177)

checks if a directory exists and create it if necessary

returns 1 if the directory exists returns 2 if there is a symlink with the name returns 3 if a new Directory is created returns False if the directory does not exists or could not be created

  • version: pk-07-11-13 check if the link source is a directory
  • version: pk-08-06-11
int pcf_checkDir (string $aDir, [boolean $createDir = False], [octal $rMask = 0770], [boolean $debug = False])
  • string $aDir: the directory
  • boolean $createDir: create the dir if not exists
  • octal $rMask: fileMask of the new directory if one is created
  • boolean $debug
pcf_checkDirName (line 219)

replaces some chars in $dirname which can cause problems

  • version: pk-07.02-28
  • todo: this function only works with linux servers for windows you can also have a drive letter like "c:"
  • todo: withpath is quick and durty coded
  • uses: pcf_checkFileName() - for each directory name
string pcf_checkDirName (string $dirName, [bool $isPath = False], [char $pathSep = _OCSP_DIRSEP_])
  • string $dirName
  • bool $isPath: $dirName is a Path with
  • char $pathSep
pcf_dirArray (line 54)

returns an array of directories like a tree

Example:

1: /home 2: /home/user1 3: /home/user1/public_html 4: /home/user2 5: /home/user2/mail ....

this function calls itself recursive until $level==0 or no subdirectories exists

this function is slow with a large directory tree

take care start point ($aDir) is set correct to avoid:

  • open_basedir restrictions
  • safe_mode restrictions
  • not getting the whole dir structure as result

void pcf_dirArray (string $aDir, array &$dirArr, [bool $goDown = TRUE], [string $path = &quot;&quot;], [string $excludes = &quot;&quot;], [int $levels = 10])
  • string $aDir: start directory
  • array &$dirArr: return array
  • bool $goDown: add subdirectory subdirs to array
  • string $path: path to add to the dirArray Value
  • string $excludes: do not add this directories and subdirectories
  • int $levels: max number of going into subdir
pcf_getDirList (line 103)

returns an array with files of a specified type in a directory

possible types:

  • F = FILE
  • D = DIRECTORY
. !D = WITHOUT DIRECTORIES (pk-04-08-18)
  • L = LINK
  • A = ALL
Combination of types are also allowed FL returns files and links

  • version: pk-04-08-19
  • version: pk-07-02-28 handle last slash
  • version: pk-07-09-04 follow links in FL an DL
  • version: pk-07-10-03 hide files ending with ~
  • version: pk-07-11-12 $blackList added
array pcf_getDirList (string $dirName, [string $type = &quot;F&quot;], [boolean $debug = FALSE], [array $blackList = array()])
  • string $dirName: (the directory)
  • string $type: (file type(s))
  • boolean $debug
  • array $blackList
pcf_getDirTree (line 247)

sets $dirArr with files, symlinks and dirs for a file tree

void pcf_getDirTree ( &$dirArr, string $startDir, [string $subDir = &quot;&quot;], [string $filter = &quot;&quot;], [string $debug = FALSE], array $dirArr)
  • array $dirArr
  • string $startDir
  • string $subDir
  • string $filter
  • string $debug
  • &$dirArr
pcf_is_dir (line 348)

checks if a file is a directory

  • since: pk-08-05-18
boolean pcf_is_dir (string $path)
  • string $path
pcf_mkdir (line 273)

creates a direcotry

bool pcf_mkdir (string $strPath, [octal $mode = 0775])
  • string $strPath
  • octal $mode: create mode
pcf_mkdirs (line 317)

creates a direcotry with parentdir if not exists

  • uses: mkdir - in bindir
bool pcf_mkdirs (string $strPath, [octal $mode = 0775], [bool $debug = FALSE])
  • string $strPath
  • octal $mode: create mode
  • bool $debug: (pk-03-12-19)
pcf_rmdir (line 290)

remove a directory and everything that's in it.

  • since: pk-07-06-17
void pcf_rmdir (string $dirname, [boolean $debug = FALSE])
  • string $dirname
  • boolean $debug

Documentation generated on Thu, 08 Jan 2009 17:47:46 +0100 by phpDocumentor 1.4.0a2