Jet\IO_Dir
An important difference from the normal use of PHP functions is that when an operation fails, a Jet\IO_Dir_Exception is always thrown.
Uses the Jet\SysConf_Jet_IO::setDirMod() setting for default directory rights.
Overview of methods
Method | Meaning of | public static exists( string $dir_path ): bool |
Indicates whether the directory exists (and is a directory). |
---|---|
public static isReadable( string $dir_path ): bool |
Indicates whether the directory is accessible - readable. |
public static isWritable( string $dir_path ): bool |
Indicates whether the directory is writable. |
public static rename( string $source_path, string $target_path, bool $overwrite_if_exists = true ): void |
Renames/moves the directory, including the contents (files and subdirectories). If the $overwrite_if_exists = true and the directory at the target location already exists, then it is first deleted and then replaced by the source directory. If the $overwrite_if_exists = false and the directory already exists at the target location, then an exception is thrown. In case of failure, it throws an exception. |
public static move( string $source_path, string $target_path, bool $overwrite_if_exists = true ): void |
Alias for the rename method. |
public static copy( string $source_path, string $target_path, bool $overwrite_if_exists = true ): void |
Copies a directory, including its contents (files and subdirectories). If the $overwrite_if_exists = true and the directory at the target location already exists, then it is first deleted and then replaced by the source directory. If the $overwrite_if_exists = false and the directory already exists at the target location, then an exception is thrown. In case of failure, it throws an exception. |
public static create( string $dir_path, bool $overwrite_if_exists = false ): void |
Creates a directory and sets its permissions. It operates recursively. Thus, in case of non-existence, it also creates parent directories (including setting default rights). In case of failure, it throws an exception. |
public static remove( string $dir_path ): void |
Deletes the directory, including all its contents. In case of failure, it throws an exception. |
public static getList( string $dir_path, string $mask = '*', bool $get_dirs = true, bool $get_files = true ): array |
According to the given mask (parameter $mask - meaning the same as in OS) returns the content (list of files and subdirectories) of the given directory. It is possible to specify whether or not you want directories (parameter $get_dirs) and files (parameter $get_files) in the list. The list is returned as an associated array, where the key is the full path and the value is the name (file/directory). In case of failure, it throws an exception. |
public static getFilesList( string $dir_path, string $mask = '*' ): array |
According to the given mask (parameter $mask - meaning the same as in OS) returns the list of files in the given directory. The list is returned as an associated array, where the key is the full path and the value is the name (file/directory). In case of failure, it throws an exception. |
public static getSubdirectoriesList( string $dir_path, string $mask = '*' ): array |
According to the given mask (parameter $mask - meaning the same as in OS) returns the list of subdirectories in the given directory. The list is returned as an associated array, where the key is the full path and the value is the name (file/directory). In case of failure, it throws an exception. |