Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

The cFileHandler class encapsules functionalities for dealing with files.

 

 

Methods:

All provided functionalities are in a public static context.

methodNameDescriptionExample
 chmod($filename, $mode)

This method can be used to change file permissions on a *nix system.

Expected parameters:

  • $filename: the full path name of a file (including the filename)
  • $mode: permission you want to set in octal mode
chmod('var/www/index.php,777);

The call of the method above grants read, write and execute rights.

copy($filename, $destination)

This method copies a file to a given location. Existing files will be overwritten

Expected parameters:

  • $filename: the full path name of a file (including the filename)
  • $destination: the full path name of a file (including the filename)

Returns: bool

chmod('var/www/index.php', '/var/www/index2.php');

The call of the method above copies the index.php file to the index2.php file.

   
exists($filename)

This method checks if a file exists at the given location

Expected parameters:

  • $filename: the full path name of a file (including the filename)

Returns: bool

exists('var/www/index.php');

The call of the method returns true if the 'var/www/index.php' file exists overwise false.

 

getExtension($basename)

This method returns the file extension of the given file

Expected parameters:

  • $filename: the full path name of a file (including the filename)

Returns: string

getExtension('var/www/index.php');

The call of the method returns the string 'php'.

 

info($filename)

This method returns information about the given file. The returing array includes the following information:

  • size (byte)
  • atime (unix timestamp: last access)
  • ctime (unix timestamp: creation)
  • mtime (unix timestamp: last modified)
  • perms (4 octal digit: file permissions)
  • extension (string: mime type of the file)

Expected parameters:

  • $filename: the full path name of a file (including the filename)

Returns: array

 
isDirectoryEmpty($dir)

This method returns checks if the given directory is empty

Expected parameters:

  • $dir: the full path name of a file (including the filename)

Returns: array

 
   
   
   
   
   
   
   
   
  • No labels