LightPHPFramework

File Class

This class provides several functions to work with files and folders.


List of public methods

Here is a list of available public methods for this class:


read_directory($directory)

Read a directory and return containing filenames as array.

Static Yes
Parameters Parameter Type Default Description
$directory String Name of directory.
Example
		
File::read_directory('downloads');
		
	

size($file, $human_readable = false)

Get size from a file.

Static Yes
Parameters Parameter Type Default Description
$file String Full path and name of given file.
$human_readable boolean Set true to return filesize as human readable string.
Example
		
File::size('downloads', true);
		
	

rename($current_filename, $new_filename)

Rename directory or file.

Static Yes
Parameters Parameter Type Default Description
$current_filename String Path to file or directory to rename.
$new_filename String New path.
Example
		
File::rename('downloads/foo.txt', 'downloads/bar.txt');
		
	

rename_directory($current_filename, $new_filename)

Alias for rename()

Example
		
File::rename_directory('downloads', 'download');
		
	

copy($source_file, $new_directory)

Copy file.

Static Yes
Parameters Parameter Type Default Description
$source_file String file to copy.
$new_directory String Target directory.
Example
		
File::copy('download/test.js', 'assets/js/test.js');
		
	

delete($file)

Delete file.

Static Yes
Parameters Parameter Type Default Description
$file String path to file to delete.
Example
		
File::delete('download/test.js');
		
	

delete_directory($directory, $delete_files = false)

Delete directory. If the directory is not empty, false will returned; exept if you set the second parameter to true.

Static Yes
Parameters Parameter Type Default Description
$directory String directory to delete.
$delete_files boolean delete containing files.
Example
		
File::delete_directory('download');
		
	

get_last_modified($file, $date_format, $timestamp)

Get the last modified date and time for given file.

Static Yes
Parameters Parameter Type Default Description
$file String File.
$date_format string 'Y-m-d' Set the date format.
$timestamp boolean false If set to true, timestamp instead of date will be returned.
Example
		
File::get_last_modified(index.php');