CRM_Utils_File
class CRM_Utils_File
class to provide simple static functions for file objects
Methods
Given a file name, determine if the file contents make it an ascii file
Given a file name, determine if the file contents make it an html file
Create a directory given a path name, creates parent directories if needed
Delete a directory given a path name, delete children directories and files if needed
Concatenate several files.
No description
Given a file name, recode it (in place!) to UTF-8
Appends a slash to the end of a string if it doesn't already end with one
Save a fake file somewhere
No description
No description
Strips comment from a possibly multiline SQL string
No description
Determine whether a given file is listed in the PHP include path.
Remove the 32 bit md5 we add to the fileName also remove the unknown tag if we added it.
Make a valid file name.
Copies a file
Get files for the extension.
Restrict access to a given directory (by planting there a restrictive .htaccess file)
Restrict remote users from browsing the given directory.
Create the base file path from which all our internal directories are offset. This is derived from the template compile directory set
Determine if a path is absolute.
No description
No description
Make a file path relative to some base dir.
Create a path to a temporary file which can endure for multiple requests.
Create a path to a temporary directory which can endure for multiple requests.
Search directory tree for files which match a glob pattern.
Determine if $child is a sub-directory of $parent
Move $fromDir to $toDir, replacing/deleting any pre-existing content.
Format file.
Return formatted file URL, like for image file return image url with image icon
Return formatted image icon
Get file icon class for specific MIME Type
Details
at line 48
static bool
isAscii(string $name)
Given a file name, determine if the file contents make it an ascii file
at line 76
static bool
isHtml(string $name)
Given a file name, determine if the file contents make it an html file
at line 110
static bool|NULL
createDir(string $path, bool $abort = TRUE)
Create a directory given a path name, creates parent directories if needed
at line 141
static
cleanDir(string $target, bool $rmdir = TRUE, bool $verbose = TRUE)
Delete a directory given a path name, delete children directories and files if needed
at line 187
static string
concat(array $files, string $delim = '')
Concatenate several files.
at line 204
static
copyDir(string $source, string $destination)
at line 230
static bool
toUtf8(string $name)
Given a file name, recode it (in place!) to UTF-8
at line 276
static string
addTrailingSlash(string $path, string $slash = NULL)
Appends a slash to the end of a string if it doesn't already end with one
at line 301
static string
createFakeFile(string $dir, string $contents = 'delete me', string $fileName = NULL)
Save a fake file somewhere
at line 319
static
sourceSQLFile(string|NULL $dsn, string $fileName, string $prefix = NULL, bool $dieOnErrors = TRUE)
at line 336
static
runSqlQuery(string|NULL $dsn, string $queryString, string $prefix = NULL, bool $dieOnErrors = TRUE)
at line 388
static string
stripComments(string $string)
Strips comment from a possibly multiline SQL string
at line 397
static bool
isExtensionSafe($ext)
at line 430
static bool
isIncludable(string $name)
Determine whether a given file is listed in the PHP include path.
at line 448
static mixed
cleanFileName($name)
Remove the 32 bit md5 we add to the fileName also remove the unknown tag if we added it.
at line 461
static string
makeFileName(string $name)
Make a valid file name.
at line 484
static mixed
duplicate($filePath)
Copies a file
at line 501
static array
getFilesByExtension(string $path, string $ext)
Get files for the extension.
at line 522
static
restrictAccess(string $dir, bool $overwrite = FALSE)
Restrict access to a given directory (by planting there a restrictive .htaccess file)
at line 548
static
restrictBrowsing($publicDir)
Restrict remote users from browsing the given directory.
at line 575
static
baseFilePath()
Create the base file path from which all our internal directories are offset. This is derived from the template compile directory set
at line 608
static bool
isAbsolute(string $path)
Determine if a path is absolute.
at line 625
static string
relativeDirectory($directory)
at line 655
static string
absoluteDirectory($directory, string|NULL $basePath = NULL)
at line 683
static string
relativize($directory, $basePath)
Make a file path relative to some base dir.
at line 706
static string,
tempnam(string $prefix = 'tmp-')
Create a path to a temporary file which can endure for multiple requests.
at line 724
static string,
tempdir(string $prefix = 'tmp-')
Create a path to a temporary directory which can endure for multiple requests.
at line 744
static array(string)
findFiles(string $dir, string $pattern, bool $relative = FALSE)
Search directory tree for files which match a glob pattern.
Note: Dot-directories (like "..", ".git", or ".svn") will be ignored.
at line 786
static bool
isChildPath(string $parent, string $child, bool $checkRealPath = TRUE)
Determine if $child is a sub-directory of $parent
at line 820
static bool
replaceDir(string $fromDir, string $toDir, bool $verbose = FALSE)
Move $fromDir to $toDir, replacing/deleting any pre-existing content.
at line 844
static
formatFile(array $param, string $fileName, array $extraParams = array())
Format file.
at line 870
static string
getFileURL(string $path, string $fileType, string $url = NULL)
Return formatted file URL, like for image file return image url with image icon
at line 908
static string
getImageURL(string $imageURL)
Return formatted image icon
at line 926
static string
getIconFromMimeType(string $mimeType)
Get file icon class for specific MIME Type