Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
Code Block
languagephp
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

Code Block
languagephp
copy('/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

Code Block
languagephp
exists('/var/www/index.php');

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

fileNameIsDot($fileName)

This method checks if the given filename is  '.' or '..'.

Expected parameters:

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

Returns: bool


Code Block
languagephp
fileNameIsDot('.');

The call of the method above returns true.

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

Code Block
languagephp
getExtension('/var/www/index.php');

The call of the method above 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 was moved to cDirHandler class with version 4.9.3 and is deprecated now.see cDirHandler
move($filename, $destination)

This method changes the location of the given file

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

Code Block
languagephp
move('/var/www/index.php', '/var/www/test/index.php');

The call of the method above moves the index.php file from path '/var/www/' to '/var/www/test/'.

 

read($filename, $length = 0, $offset = 0, $reverse = false)

This method reads bytes from the given file.

Expected parameters:

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

Optional parameters:

  • $length (int: number of bytes to read)
  • $offset (int: byte offset)
  • $reverse (bool: start reading from the front or from the end of the file)

Returns: bool

Code Block
languagephp
read('/var/www/index.php');

The call of the method above returns the content of the index.php file.

readable($filename)

This method checks if the given file is readable.

Expected parameters:

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

Returns: bool

Code Block
languagephp
readable('/var/www/index.php');

The call of the method above moves returns true if the index.php file is readable, otherwise false.

readLine($filename, $lines = 0, $lineoffset = 0)

This method reads a line from the given file.

Expected parameters:

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

Optional parameters:

  • $lines(int: number of lines to read)
  • $lineoffset (int: lines offset)

Returns:

  • string: read only one line
  • array of strings: read more than one line
  • bool: read nothing
     
Code Block
languagephp
readableLine('/var/www/index.php');

The call of the method above returns the first line of the content from the index.php file.

recursiveCopy($filename, $destination)

This method was moved to cDirHandler class with version 4.9.3 and is deprecated now.

see cDirHandler
recursiveRmdir($dirname)This method was moved to cDirHandler class with version 4.9.3 and is deprecated now.

see cDirHandler

remove($filename)

This method removes the given file from the filesystem.

Expected parameters:

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

Returns: bool

Code Block
languagephp
remove('/var/www/index.php');

The call of the method above removes the index.php file.

 

 

 

rename($filename, $new_filename)

This method renames the given file from the filesystem.

Expected parameters:

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

Returns: bool

Code Block
languagephp
rename('/var/www/index.php','/var/www/index.html');

The call of the method above renames the index.php file to index.html.

setDefaultDirPerms($pathname)This method was moved to cDirHandler class with version 4.9.3 and is deprecated now.see cDirHandler
setDefaultFilePerms($filename)

This method sets default permissions to the given file

Expected parameters:

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

Returns: bool

 
truncate($filename)

This method clears the content of the given file

Expected parameters:

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

Returns: bool

Code Block
languagephp
truncate('/var/www/index.php');

The call of the method above removes the content of the index.php file.

validateFilename($filename, $notifyAndExitOnFailure = true)

This method validates the filename of the given file with CONENTIDO standard.

Expected parameters:

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

Optional parameters:

  • $notifyAndExitOnFailure(bool: show notification and exit the script)

Returns: bool

 
write($filename, $content, $append = false)

This method writes data to the given file

Expected parameters:

  • $filename: the full path name of a file (including the filename)
  • $content: content you want to write

Optional parameters:

  • $append(bool: flag to append the content to a existing file

Returns: bool

Code Block
languagephp
write('/var/www/index.php','hello world!');

The call of the method above writes the string 'hello world!' in the index.php file.

 writeable($filename)

This method checks if the given file is writeable

Expected parameters:

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

Returns: bool

Code Block
languagephp
writeable('/var/www/index.php');

The call of the method above returns true if the index.php file is writeable, otherwise false.

writeLine($filename, $content, $append = false)

This method writes a line to the given file

Expected parameters:

  • $filename: the full path name of a file (including the filename)
  • $content: content you want to write

Optional parameters:

  • $append(bool: flag to append the content to a existing file

Returns: bool

Code Block
languagephp
writeLine('/var/www/index.php','hello world!');

The call of the method above returns writes the line 'hello world!' to the index.php file.