weew/helpers-filesystem

Collection of useful filesystem helpers.

v1.2.1 2016-07-21 11:18 UTC

This package is not auto-updated.

Last update: 2024-11-05 22:46:52 UTC


README

Build Status Test Coverage Version Licence

Table of contents

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])