Folder

True\Folder wraps the common directory operations — create, remove, copy, move, list, check empty — behind a tidy API that throws on failure so you don't have to litter your code with @ and return-value checks.

Common operations

// Create (recursive by default)
True\Folder::create('/path/to/new/directory');
True\Folder::create('/path/to/new/directory', 0775);   // custom mode

// Recursively remove a directory and everything in it
True\Folder::remove('/path/to/directory');

// Copy a directory tree
True\Folder::copy('/source/directory', '/destination/directory');

// Move (rename) a directory
True\Folder::move('/source/directory', '/destination/directory');

Listing & emptiness

$contents = True\Folder::listContents('/path/to/directory');
foreach ($contents as $item) {
    echo $item . PHP_EOL;
}

if (True\Folder::isEmpty('/path/to/directory')) {
    echo "Nothing here.";
}

Unique-name generation

When you need a directory name that doesn't collide with an existing one (uploads, session sandboxes, etc.), makeUnique() returns the full path of a freshly created directory:

$dir = True\Folder::makeUnique('/path/to/parent', 'upload-');
// => "/path/to/parent/upload-a1b2c3"

API

MethodBehavior
create(string $path, int $mode = 0755, bool $recursive = true): boolCreate the directory if it doesn't already exist.
remove(string $dir): voidRecursively delete the directory. Throws on failure.
copy(string $source, string $destination): voidRecursively copy the tree. Throws on failure.
move(string $source, string $destination): voidRename / move the directory. Throws on failure.
listContents(string $path): arrayReturns names of all files and subdirectories. Throws if $path isn't a directory.
isEmpty(string $path): boolWhether the directory has no entries.
makeUnique(string $path, string $prefix = ''): stringCreate and return a freshly named subdirectory.