\Fuman_Util_File

File system path util

Summary

Methods
Properties
Constants
sanitizeFileName()
isValidFileExtension()
combinePath()
prependRootPath()
findFiles()
findPhpFiles()
recursiveGlob()
glob()
getClassName()
deleteFile()
deleteDirectory()
globClasses()
getMimeType()
No public properties found
No constants found
No protected methods found
$_mimeTypes
N/A
No private methods found
No private properties found
N/A

Properties

$_mimeTypes

$_mimeTypes : 

Type

Methods

sanitizeFileName()

sanitizeFileName(string  $name, boolean  $toLower = true, string  $fallbackChar = '-') : string

Sanitized file name

Parameters

string $name
boolean $toLower
string $fallbackChar

Returns

string

isValidFileExtension()

isValidFileExtension(string  $name, string  $filter) : boolean

Does the file name match the given filter (e.g *.jpg,*.png)

Parameters

string $name
string $filter

Returns

boolean

combinePath()

combinePath(string  $path, string  $path1) : string

Combine path fragments to one path

Parameters

string $path
string $path1

Returns

string

prependRootPath()

prependRootPath(string  $path, boolean  $isDirectoryPath = false) : string

Prepends root path

Parameters

string $path
boolean $isDirectoryPath

Returns

string

findFiles()

findFiles(string  $dir = '.', null|array  $extensions = null, boolean  $addDirs = false) : array

Find files in path

Parameters

string $dir
null|array $extensions
boolean $addDirs

Returns

array

findPhpFiles()

findPhpFiles(string  $dir = '.', boolean  $excludeLibraries = true) : array

Find php files in path

Parameters

string $dir
boolean $excludeLibraries

(paths with /library/ will be excluded)

Returns

array

recursiveGlob()

recursiveGlob(string  $path, string  $cleanPath = '', boolean  $returnFileName = false) : array<mixed,string>|array<mixed,\stdClass>

Collects files by a recursive Pattern

Note: For the examples i used ! for slash to prevent comment parsing by php

Format Example:

 Fuman_Util_File::recursiveGlob(FUMAN_APP_PATH . '*!theme!*!css!*.css');

Its also possible to clean the file path, to prevent long file paths:

 Fuman_Util_File::recursiveGlob(FUMAN_APP_PATH . '*!theme!*!css!*.css', FUMAN_ROOT_PATH);

Parameters

string $path

Glob Path to be searched

string $cleanPath

Path with which the found paths will be cleaned

boolean $returnFileName

If true, the result will be a object with name and path properties

Returns

array<mixed,string>|array<mixed,\stdClass> —

Depends on the $returnFileName param

glob()

glob(string  $path) : array

Glob wrapper (Some installations returns null and not an array)

Parameters

string $path

Returns

array

getClassName()

getClassName(string  $path) : string

Converts path to a class name (uses token_get_all)

Parameters

string $path

Returns

string

deleteFile()

deleteFile(string  $path, string|null  $cleanUpUntilPath = null) : boolean

Deletes a file If cleanUpUntilPath is given, it will try to delete folders until this path

Parameters

string $path
string|null $cleanUpUntilPath

Returns

boolean

deleteDirectory()

deleteDirectory(string  $dir, boolean  $clean = false) : boolean

Deletes an directory

Parameters

string $dir
boolean $clean

if its true, it deletes recursive all files and directories

Returns

boolean

globClasses()

globClasses(string  $path, array<mixed,string>|null  $parents) : array

Returns an array with the class names

Parameters

string $path
array<mixed,string>|null $parents

concretes of an interface, abstract or class (Prefix with ! means NOT)

Returns

array

getMimeType()

getMimeType(string  $path) : string

Gets mime type for path/filename (mime_content_type is deprecated) Thanks to apache project (http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types)

Parameters

string $path

Returns

string