Skip to content

icms_core_Filesystem

Raimondas Rimkevičius edited this page Mar 9, 2020 · 1 revision
Notice: Wiki was automatic generated from project sources as project API documentation. Do not edit manually!

icms_core_Filesystem

A static class for file system functions

Using a static class instead of a include file with global functions, along with autoloading of classes, reduces the memory usage and only includes files when needed.

  • Class name: icms_core_Filesystem
  • Namespace:

Methods

chmod

bool icms_core_Filesystem::chmod(string target, int mode)

Change the permission of a file or folder Replaces icms_chmod()

  • Visibility: public
  • This method is static.

Arguments

  • target string - <p>target file or folder</p>
  • mode int - <p>permission</p>

mkdir

bool icms_core_Filesystem::mkdir(string target, int mode, string base, array metachars)

Safely create a folder and any folders in between Replaces icms_mkdir()

  • Visibility: public
  • This method is static.

Arguments

  • target string - <p>path to the folder to be created</p>
  • mode int - <p>permissions to set on the folder. This is affected by umask in effect</p>
  • base string - <p>root location for the folder, ICMS_ROOT_PATH, for example</p>
  • metachars array - <p>Characters to exclude from a valid path name</p>

cleanFolders

mixed icms_core_Filesystem::cleanFolders(string dir, bool remove_admin_cache)

Removes the content of a folder.

Replaces icms_clean_folders()

  • Visibility: public
  • This method is static.

Arguments

  • dir string - <p>The folder path to cleaned. Must be an array like: array('cache' => ICMS_CACHE_PATH . "/");</p>
  • remove_admin_cache bool - <p>True to remove admin cache, if required.</p>

cleanWriteFolders

mixed icms_core_Filesystem::cleanWriteFolders()

Clean up all writable folders Replaces icms_cleaning_write_folders()

  • Visibility: public
  • This method is static.

copyRecursive

bool icms_core_Filesystem::copyRecursive(string source, string dest)

Copy a file, or a folder and its contents Replaces icms_copyr()

  • Visibility: public
  • This method is static.

Arguments

  • source string - <p>The source</p>
  • dest string - <p>The destination</p>

deleteFile

bool icms_core_Filesystem::deleteFile(string dirname)

Deletes a file Replaces icms_deleteFile()

  • Visibility: public
  • This method is static.

Arguments

  • dirname string - <p>path of the file</p>

copyStream

bool icms_core_Filesystem::copyStream(string src, string dest)

Copy a file, or a folder and its contents from a website to your host Replaces icms_stream_copy()

  • Visibility: public
  • This method is static.

Arguments

  • src string - <p>The source</p>
  • dest string - <p>The destination</p>

deleteRecursive

bool icms_core_Filesystem::deleteRecursive(string dir, bool deleteRootToo)

Recursively delete a directory or its contents Replaces icms_unlinkRecursive()

  • Visibility: public
  • This method is static.

Arguments

  • dir string - <p>Directory name</p>
  • deleteRootToo bool - <p>Delete specified top-level directory as well</p>

writeIndexFile

bool icms_core_Filesystem::writeIndexFile(string path)

Writes index file Replaces xoops_write_index_file() from cp_functions.php

  • Visibility: public
  • This method is static.

Arguments

  • path string - <p>path to the file to write</p>

generateChecksum

mixed icms_core_Filesystem::generateChecksum()

Create a checksum file for your installation directory

  • Visibility: public
  • This method is static.

validateChecksum

mixed icms_core_Filesystem::validateChecksum()

Validate the current installation directory against an existing checksum file This reports any changes to your installation directory - added, removed or changed files

  • Visibility: public
  • This method is static.

getDirList

array icms_core_Filesystem::getDirList(string dirname, array ignore, bool hideDot)

Gets a list of all directories within a path

  • Visibility: public
  • This method is static.

Arguments

  • dirname string - <p>A path to a directory</p>
  • ignore array - <p>A list of folders to ignore</p>
  • hideDot bool - <p>Hide folders starting with a dot?</p>

getFileList

array icms_core_Filesystem::getFileList(string dirname, string prefix, array extension, bool hideDot)

Get a list of files in a directory

This can be used for several different situations - To retrieve an array of images, use getFileList($dirname, $prefix, array('gif', 'jpg', 'png')) To retrieve an array of fonts, use getFileList($dirname, $prefix, array('ttf')) To retrieve an array of HTML files, use getFileList($dirname, $prefix, array('html', 'htm', 'xhtml'))

  • Visibility: public
  • This method is static.

Arguments

  • dirname string - <p>A path to a directory</p>
  • prefix string - <p>A prefix to add to the beginning of the file names</p>
  • extension array - <p>Filter the list by these extensions</p>
  • hideDot bool - <p>Hide files starting with a dot?</p>

writeFile

bool icms_core_Filesystem::writeFile(string contents, string filename, string extension, string location, bool overwrite)

Create and write contents to a file

General file system permissions apply

  • if the file exists, you need write permissions for the file
  • if the file does not exist, you need write permissions for the path
  • Visibility: public
  • This method is static.

Arguments

  • contents string - <p>The contents to be written to the file</p>
  • filename string - <p>The filename</p>
  • extension string - <p>The extension of the new file</p>
  • location string - <p>The path to the new file</p>
  • overwrite bool - <p>If TRUE, overwrite any existing file. If FALSE, append to any existing file</p>

combineFiles

mixed icms_core_Filesystem::combineFiles(array files, string type, bool minimize, bool replace, int maxage, string location)

Combine several files of the same type (css or js) and write to a single file

  • Visibility: public
  • This method is static.

Arguments

  • files array - <p>An array of files, with the URI of the file as the key</p>
  • type string - <p>Common extension of the files (css or js)</p>
  • minimize bool - <p>If TRUE, minimize the file (reduce whitespace and line breaks, default is FALSE</p>
  • replace bool - <p>If TRUE, replace any existing file with an updated version</p>
  • maxage int - <p>Maximum age, in seconds, of the file before updating. Default 0 = never expire. $replace value overrides $maxage</p>
  • location string - <p>Path of the output file</p>

rename

mixed icms_core_Filesystem::rename(\str oldname, \str newname, bool overwrite)

Rename or relocate a file or directory

General file system permissions apply

  • if the file exists, you need write permissions for the file
  • if the file does not exist, you need write permissions for the path
  • Visibility: public
  • This method is static.

Arguments

  • oldname str - <p>File or directory to rename, with path</p>
  • newname str - <p>New name, with full path</p>
  • overwrite bool - <p>If TRUE, overwrite an existing file with the same name</p>

getImgList

mixed icms_core_Filesystem::getImgList(mixed dirname, mixed prefix, mixed extension)
  • Visibility: public
  • This method is static.

Arguments

  • dirname mixed
  • prefix mixed
  • extension mixed

getFontList

mixed icms_core_Filesystem::getFontList(mixed dirname, mixed prefix, mixed extension)
  • Visibility: public
  • This method is static.

Arguments

  • dirname mixed
  • prefix mixed
  • extension mixed

getPhpFiles

mixed icms_core_Filesystem::getPhpFiles(mixed dirname, mixed prefix, mixed extension)
  • Visibility: public
  • This method is static.

Arguments

  • dirname mixed
  • prefix mixed
  • extension mixed

getHtmlFiles

mixed icms_core_Filesystem::getHtmlFiles(mixed dirname, mixed prefix, mixed extension)
  • Visibility: public
  • This method is static.

Arguments

  • dirname mixed
  • prefix mixed
  • extension mixed
Clone this wiki locally