Filesystem helpers
, (*1)
Table of contents
Installation
composer require weew/helpers-filesystem, (*2)
Introduction
This tiny library provides various helper functions to deal with files and directories in a concise and easy way., (*3)
Functions
file_get_directory
Get name of the file's directory., (*4)
string file_get_directory(string $path), (*5)
file_get_extension
Get name of the file's directory., (*6)
string file_get_extension(string $path), (*7)
file_get_name
Get name of the file's directory., (*8)
string file_get_name(string $path), (*9)
file_read
Read contents of a file., (*10)
mixed file_read(string $path), (*11)
file_create
Create a file and all necessary subdirectories., (*12)
bool file_create(string $path), (*13)
file_write
Write to a file., (*14)
bool file_write(string $path, string $content), (*15)
file_append
Append contents to the end of file., (*16)
bool file_append(string $path, string $content), (*17)
file_prepend
Prepend contents to the beginning of file., (*18)
bool file_prepend(string $path, string content), (*19)
file_delete
Delete a file., (*20)
bool file_delete(string $path), (*21)
file_rename
Move a file from one location to another and create all necessary subdirectories., (*22)
bool file_rename(string $oldPath, string $newPath), (*23)
file_copy
Copy a file from one location to another and create all necessary subdirectories., (*24)
bool file_copy(string $oldPath, string $newPath), (*25)
file_rename
Rename file at the given path., (*26)
bool file_rename(string $path, $newName), (*27)
directory_get_name
Get name of the file's directory., (*28)
string directory_get_name(string $path), (*29)
directory_get_parent
Get path of the parent directory., (*30)
string directory_get_parent(string $path), (*31)
directory_create
Create a directory and all subdirectories., (*32)
bool directory_create(string $path [, $mode = 0777]), (*33)
directory_delete
Delete a directory and all of its files., (*34)
bool directory_delete(string $path), (*35)
directory_exists
Check if a directory exists., (*36)
bool directory_exists(string $path), (*37)
directory_rename
Rename a directory., (*38)
bool directory_rename(string $path, string $newName), (*39)
directory_move
Move directory to the specified path., (*40)
bool directory_move(string $oldPath, string $newPath), (*41)
directory_copy
Copy a directory and all of its contents to the specified path and create all necessary subdirectories., (*42)
bool directory_copy(string $oldPath, string $newPath), (*43)
directory_clear
Delete all files and directories inside a directory., (*44)
directory_clear(string $path), (*45)
directory_list
Return a list of files and directories. $absolute indicates whether the paths should be relative or absolute., (*46)
string[] directory_list(string $path [, $absolute = false]), (*47)
directory_list_files
Return a list of files. $absolute indicates whether the paths should be relative or absolute., (*48)
string[] directory_list_files(string $path [, $absolute = false]), (*49)
directory_list_directories
Return a list of directories. $absolute indicates whether the paths should be relative or absolute., (*50)
string[] directory_list_directories(string $path [, $absolute = false]), (*51)