To manage files and directories within a domain, use the
pm_FileManager
class. This class lets you create and remove files and directories,
check for existence of files and directories, read and write data to
files, and also change file and directory permissions (only on Linux).
Note: For security considerations, we strongly recommend that you do not
use system calls such as fopen or file_get_contents in the code
of your extension. When you use such calls, the extension works with
files on behalf of the psaadm
user. In turn, if you use the
pm_FileManager class, the manipulations are performed on behalf of
the domain owner’s system user.
Descriptions and usage examples for some of the methods can be found
below.
scanDir() - returns a list of files and directories inside the
specified path.
Usage
array scanDir(string $path [, bool $skipDots = false [, bool $showSystemFiles = true ]])
Parameters
-
path (type: string)
The directory that will be scanned.
-
skipDots (type: boolean, default value: false)
If the optional parameter skipDots is set to “true”, then the root
directories “..” and “.” will be excluded from the resulting array,
otherwise they will be included. -
showSystemFiles (type: boolean, default value: true)
If the optional parameter showSystemFiles is set to “true”, then
hidden files (for example, system files) will be included in
resulting array, otherwise they will be absent.
Return Values
Returns an array containing the files and directories in the directory.
Examples
Directory tree
$ ls -a <span class="…