The WebAbility® Network Developers - Documentation
WebAbility Site
\core\WAFile reference

I. WAFile Structure:


- namespace:
\core\

It is a static object
- Does not have superclass
- Does not have subclasses

II. Description:


This is a static class that contains some mass files functions.

You can copy a full directory with its sub directories, or delete it.
It also permits to create a full path of directories without having to create each directly individually.

If there is any problem on the files operation, a FileException will be thrown.


Those are very dangerous functions since you can delete virtually anything from your hard disk with them.

III. Reference:


3.1. Contructor:

none

3.2. Constants:

none

3.3. Attributes:

none

3.4. Methods:


public void static setDirMask($dirmask)
Will fix the default mask for directories creation. This function is useless on windows.
  • $dirmask: octal, the directory mask. It is fixed to 0700 by default (rwx------).

public octal static getDirMask()
Returns the actual directory mask.

public void static setFileMask($filemask)
Will fix the default mask for files creation/copy. This function is useless on windows.
  • $filemask: octal, the file mask. It is fixed to 0600 by default (rw-------).

public octal static getFileMask()
Returns the actual file mask.

public void static createDirectory($dir, $subpath, $mask)
Will check and create all the path $subpath. $subpath is relative to $dir. $dir will not be create and must already exists. If a directory level is missing in $subpath, it will be automatically created.
  • $dir: path string, the base directory where the creation will happen. It must already exists.
  • $subpath: path string, the path into $dir to create. Any directory not existing will be created.
  • $mask: octal, the directory mask. Optional parameter. If it is not set, the method will use the default already set directory mask.

public void static copyFile($origin, $destination)
Will copy a file or a directory from $origin to $destination. If $origin is a directory, it will be recursively copied.
If $origin is a directory, the method calls copyStructure automatically.
  • $origin: path string, the origin file or directory.
  • $destination: path string, the destination directory.

public void static copyStructure($origin, $destination)
Will copy a file or a directory from $origin to $destination. If $origin is a directory, it will be recursively copied.
  • $origin: path string, the origin file or directory.
  • $destination: path string, the destination directory.

public void static deleteALL($dir, $reConstraint)
Will delete recursively a directory.
A double protection has been implemented in the method:
- The path cannot be less than 10 character length (so you cannot delete root directories).
- The path must match a regular expression.
This is a very dangerous function since you can delete virtually anything from your hard disk with it if $dir is set to '/' or with a wrong value.
  • $dir: path string, the base directory to start the deletion.
  • $reConstraint: regular expression. You must put in this variable a regular expression that must match your directory. This is a security to be sure you delete the right directory. The expression is tested with a preg_match function. If the filter match, then the directory can be deleted. It is imperative you check the size and structure of your directory with the regular expression.