WireFileTools class

Helpers for working with files and directories.

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the WireFileTools class also inherits all the methods and properties of: Wire.

Show class?             Show args?        

Common

NameReturnSummary 
WireFileTools::chmod(string $path)
boolChange the read/write mode of a file or directory, consistent with ProcessWire's configuration settings 
WireFileTools::copy(string $src, string $dst)
boolCopy all files recursively from one directory ($src) to another directory ($dst) 
WireFileTools::filePutContents(string $filename, $contents)
int boolCreate (overwrite or append) a file, put the $contents in it, and adjust permissions 
WireFileTools::find(string $path)
arrayFind all files in the given $path recursively, and return a flat array of all found filenames 
WireFileTools::mkdir(string $path)
boolCreate a directory that is writable to ProcessWire and uses the defined $config chmod settings 
WireFileTools::rename(string $oldName, string $newName)
boolRename a file or directory and update permissions 
WireFileTools::rmdir(string $path)
boolRemove a directory and optionally everything within it (recursively) 
WireFileTools::send(string $filename)
(nothing)Send the contents of the given filename to the current http connection 
WireFileTools::unlink(string $filename)
boolUnlink/delete file with additional protections relative to PHP unlink() 

Advanced

Includes

Filenames

NameReturnSummary 
WireFileTools::fileInPath(string $file, string $path)
boolIs given $file name in given $path name? (aka: is $file a subdirectory somewhere within $path) 
WireFileTools::unixDirName(string $dir)
stringConvert given directory name to use unix slashes and enforce trailing or no-trailing slash 
WireFileTools::unixFileName(string $file)
stringConvert given file name to use unix slashes (if it isn’t already) 

Additional methods and properties

In addition to the methods and properties above, WireFileTools also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.123

Twitter updates

  • New post: In this week’s post, we’ll take a look a look at the new website and focus on some parts of it and how they were built. Then we’ll dive into the latest version of ProcessWire on the dev branch, version 3.0.124— More
    11 January 2019
  • New ProcessWire main site rebuild ready for preview— More
    4 January 2019
  • Happy Holidays! This latest master version of ProcessWire contains hundreds of new additions, fixes, optimizations and more. This post covers all the highlights— More
    21 December 2018

Latest news

  • ProcessWire Weekly #244
    In the 244th issue of ProcessWire Weekly we'll cover the latest core updates, introduce the new processwire.com site, ask a PHP version related question in the weekly poll, and showcase the site of an open source room bookings app. Read on!
    Weekly.pw / 12 January 2019
  • ProcessWire 3.0.124 and new website launched
    In this week’s post, we’ll take a look a look at the new website and focus on some parts of it and how they were built. Then we’ll dive into the latest version of ProcessWire on the dev branch, version 3.0.124.
    Blog / 11 January 2019
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like superbude.de. ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH