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

Class: File_Util

Source Location: /File_Util-1.0.0/File/Util.php

Class Overview


File_Util


Author(s):

Methods


Inherited Variables

Inherited Methods


Class Details

[line 57]
File_Util

File and directory utility functions.

  • Access: public


[ Top ]


Method Detail

buildPath   [line 69]

void buildPath( array $parts, [string $separator = DIRECTORY_SEPARATOR])

Returns a string path built from the array $pathParts. Where a join occurs multiple separators are removed. Joins using the optional separator, defaulting to the PHP DIRECTORY_SEPARATOR constant.
  • Access: public

Parameters:

array   $parts   —  Array containing the parts to be joined
string   $separator   —  The directory seperator

[ Top ]

isAbsolute   [line 177]

boolean isAbsolute( string $path)

Returns boolean based on whether given path is absolute or not.
  • Return: True if the path is absolute, false if it is not
  • Access: public

Parameters:

string   $path   —  Given path

[ Top ]

isIncludable   [line 201]

string isIncludable( string $file, [string $sep = DIRECTORY_SEPARATOR])

Checks for a file's existence, taking the current include path into consideration

This method can be called statically (e.g., File_Util::isIncludable('config.php'))

  • Return: the includable path
  • Access: public

Parameters:

string   $file   — 
string   $sep   —  the directory separator (optional)

[ Top ]

listDir   [line 344]

array listDir( string $path, [int $list = FILE_LIST_ALL], [int $sort = FILE_SORT_NONE], [mixed $cb = null])

List Directory

The final argument, $cb, is a callback that either evaluates to true or false and performs a filter operation, or it can also modify the directory/file names returned. To achieve the latter effect use as follows:

  1.  <?php
  2.  function uc(&$filename{
  3.      $filename strtoupper($filename);
  4.      return true;
  5.  }
  6.  $entries File_Util::listDir('.'FILE_LIST_ALLFILE_SORT_NONE'uc');
  7.  foreach ($entries as $e{
  8.      echo $e->name"\n";
  9.  }
  10.  ?>

  • Access: public

Parameters:

string   $path   — 
int   $list   — 
int   $sort   — 
mixed   $cb   — 

[ Top ]

pathInRoot   [line 304]

bool pathInRoot( string $path, string $root)

Check whether path is in root path
  • Access: public

Parameters:

string   $path   — 
string   $root   — 

[ Top ]

prefixed   [line 498]

string prefixed( integer $size, [integer $decimals = 1], [boolean $long = false], [boolean $oldStyle = true], [boolean $useBiBytes = true])

Returns the filesize using a prefix like "kilo", "mebi" or "giga"
  • Return: The filesize in human readable format
  • Author: Christian Weiske <cweiske@cweiske.de>

Parameters:

integer   $size   —  The size to convert
integer   $decimals   —  The number of decimals to use
boolean   $long   —  Use long names (kilobyte) instead of short ones (kB)
boolean   $oldStyle   —  If the old style should be used
boolean   $useBiBytes   —  If the "BiBytes" names should be used [applies only to !$bOldStyle]

[ Top ]

realPath   [line 258]

string realPath( string $path, [string $separator = DIRECTORY_SEPARATOR])

Get real path (works with non-existant paths)
  • Access: public

Parameters:

string   $path   — 
string   $separator   — 

[ Top ]

relativePath   [line 224]

string relativePath( string $path, string $root, [string $separator = DIRECTORY_SEPARATOR])

Get path relative to another path
  • Access: public

Parameters:

string   $path   — 
string   $root   — 
string   $separator   — 

[ Top ]

skipRoot   [line 95]

string skipRoot( string $path)

Returns a path without leading / or C:\. If this is not present the path is returned as is.
  • Return: The processed path or the path as is
  • Access: public

Parameters:

string   $path   —  The path to be processed

[ Top ]

sortFiles   [line 385]

array sortFiles( array $files, int $sort)

Sort Files
  • Access: public

Parameters:

array   $files   — 
int   $sort   — 

[ Top ]

switchExt   [line 456]

string|array switchExt( string|array $filename, string $to, [string $from = null], [bool $reverse = false])

Switch File Extension
  • Access: public

Parameters:

string|array   $filename   — 
string   $to   —  new file extension
string   $from   —  change only files with this extension
bool   $reverse   —  change only files not having $from extension

[ Top ]

tmpDir   [line 115]

string tmpDir( )

Returns the temp directory according to either the TMP, TMPDIR, or TEMP env variables. If these are not set it will also check for the existence of /tmp, %WINDIR%\temp
  • Return: The system tmp directory
  • Access: public

[ Top ]

tmpFile   [line 161]

string tmpFile( [string $dirname = null])

Returns a temporary filename using tempnam() and File::tmpDir().
  • Return: Filename and path of the tmp file
  • Access: public

Parameters:

string   $dirname   —  Optional directory name for the tmp file

[ Top ]


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