weew / helpers-filesystem
Collection of useful filesystem helpers.
Installs: 10 551
Dependents: 4
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- weew/helpers-string: ^1.0.0
Requires (Dev)
- phpunit/phpunit: ^4.7
- satooshi/php-coveralls: ^0.6.1
README
Table of contents
- Installation
- Introduction
- Functions
- file_get_directory
- file_get_extension
- file_get_name
- file_read
- file_create
- file_write
- file_append
- file_prepend
- file_delete
- file_move
- file_copy
- file_rename
- directory_get_name
- directory_get_parent
- directory_create
- directory_delete
- directory_exists
- directory_rename
- directory_move
- directory_copy
- directory_clear
- directory_list
- directory_list_files
- directory_list_directories
Installation
composer require weew/helpers-filesystem
Introduction
This tiny library provides various helper functions to deal with files and directories in a concise and easy way.
Functions
file_get_directory
Get name of the file's directory.
string file_get_directory(string $path)
file_get_extension
Get name of the file's directory.
string file_get_extension(string $path)
file_get_name
Get name of the file's directory.
string file_get_name(string $path)
file_read
Read contents of a file.
mixed file_read(string $path)
file_create
Create a file and all necessary subdirectories.
bool file_create(string $path)
file_write
Write to a file.
bool file_write(string $path, string $content)
file_append
Append contents to the end of file.
bool file_append(string $path, string $content)
file_prepend
Prepend contents to the beginning of file.
bool file_prepend(string $path, string content)
file_delete
Delete a file.
bool file_delete(string $path)
file_rename
Move a file from one location to another and create all necessary subdirectories.
bool file_rename(string $oldPath, string $newPath)
file_copy
Copy a file from one location to another and create all necessary subdirectories.
bool file_copy(string $oldPath, string $newPath)
file_rename
Rename file at the given path.
bool file_rename(string $path, $newName)
directory_get_name
Get name of the file's directory.
string directory_get_name(string $path)
directory_get_parent
Get path of the parent directory.
string directory_get_parent(string $path)
directory_create
Create a directory and all subdirectories.
bool directory_create(string $path [, $mode = 0777])
directory_delete
Delete a directory and all of its files.
bool directory_delete(string $path)
directory_exists
Check if a directory exists.
bool directory_exists(string $path)
directory_rename
Rename a directory.
bool directory_rename(string $path, string $newName)
directory_move
Move directory to the specified path.
bool directory_move(string $oldPath, string $newPath)
directory_copy
Copy a directory and all of its contents to the specified path and create all necessary subdirectories.
bool directory_copy(string $oldPath, string $newPath)
directory_clear
Delete all files and directories inside a directory.
directory_clear(string $path)
directory_list
Return a list of files and directories. $absolute
indicates whether the paths should be relative or absolute.
string[] directory_list(string $path [, $absolute = false])
directory_list_files
Return a list of files. $absolute
indicates whether the paths should be relative or absolute.
string[] directory_list_files(string $path [, $absolute = false])
directory_list_directories
Return a list of directories. $absolute
indicates whether the paths should be relative or absolute.
string[] directory_list_directories(string $path [, $absolute = false])