Virtual filesystems.

package commandr

 Methods

Is it a directory?

_is_dir(\?array $dir = null) : boolean

Parameters

$dir

\?array

Path to check (null: current dir is used)

Returns

booleanDirectory?

Is it a file?

_is_file(array $dir) : boolean

Parameters

$dir

array

Path (with filename) to use

Returns

booleanDirectory?

Convert a string-form path to an array.

_pwd_to_array(string $pwd) : array

Parameters

$pwd

string

Path

Returns

arrayArray-form path

Append to a file.

append_file(array $to_append, string $contents) : boolean

Parameters

$to_append

array

The file to which to append

$contents

string

The contents to append

Returns

booleanSuccess?

Change the current working directory. Equivalent to Unix "cd".

change_directory(array $target_directory) : boolean

Parameters

$target_directory

array

The target directory path

Returns

booleanSuccess?

Constructor function. Setup a virtual filesystem, but do nothing with it.

commandr_fs() 

Copy a directory. Equivalent to Unix "cp".

copy_directory(array $to_copy, array $destination) : boolean

Parameters

$to_copy

array

The directory to copy

$destination

array

The destination path

Returns

booleanSuccess?

Copy a file. Equivalent to Unix "cp".

copy_file(array $to_copy, array $destination) : boolean

Parameters

$to_copy

array

The file to copy

$destination

array

The destination path

Returns

booleanSuccess?

Return a directory and file listing of the current working directory. Equivalent to Unix "ls".

listing(\?array $dir = null) : array

Parameters

$dir

\?array

An alternate directory in which to perform the action (null: current directory is used)

Returns

arrayDirectories and files in the current working directory

Create a directory under the current working directory. Equivalent to Unix "mkdir".

make_directory(array $directory) : boolean

Parameters

$directory

array

The new directory's path and name

Returns

booleanSuccess?

Move a directory. Equivalent to Unix "mv".

move_directory(array $to_move, array $destination) : boolean

Parameters

$to_move

array

The directory to move

$destination

array

The destination path

Returns

booleanSuccess?

Move a file. Equivalent to Unix "mv".

move_file(array $to_move, array $destination) : boolean

Parameters

$to_move

array

The file to move

$destination

array

The destination path

Returns

booleanSuccess?

Convert a directory contents structure into a template parameter structure.

prepare_dir_contents_for_listing(array $entries) : array

Parameters

$entries

array

Structure

Returns

arrayTemplate parameter structure

Return the current working directory of the virtual filesystem. Equivalent to Unix "pwd".

print_working_directory(boolean $array_form = false) : mixed

Parameters

$array_form

boolean

Return the pwd in array form?

Returns

mixedThe current working directory (array or string)

Convert an array-form path to a string.

pwd_to_string(\?array $pwd = null) : string

Parameters

$pwd

\?array

Path (null: use $this->pwd)

Returns

stringString-form path

Read a file and return the contents.

read_file(array $to_read) : \~string

Parameters

$to_read

array

The file to read

Returns

\~stringThe file contents (false: failure)

Remove a directory under the current working directory. Equivalent to Unix "rmdir".

remove_directory(array $directory) : boolean

Parameters

$directory

array

The directory-to-remove's path and name

Returns

booleanSuccess?

Remove a file. Equivalent to Unix "rm".

remove_file(array $to_remove) : boolean

Parameters

$to_remove

array

The file to remove

Returns

booleanSuccess?

Write to a file; create the file if it doesn't exist.

write_file(array $to_write, string $contents) : boolean

Parameters

$to_write

array

The file to write

$contents

string

The contents to write

Returns

booleanSuccess?

Fill out a hardcoded meta-dir to use our more detailed internal format.

_convert_meta_dir_to_detailed_dir(array $_inspected_dir) : array

Parameters

$_inspected_dir

array

Simple list of directories under here

Returns

arrayFull detailed directory contents

Get details of the current meta directory.

_discern_meta_dir(array $meta_dir, string $meta_root_node, string $meta_root_node_type, \?array $target_dir = null) : \~array

Parameters

$meta_dir

array

Meta directory result: returned by reference

$meta_root_node

string

Meta root node result: returned by reference

$meta_root_node_type

string

Meta root node type result: returned by reference

$target_dir

\?array

Directory (null: current directory is used)

Returns

\~arrayCurrent directory contents (false: error)

Return the contents of the given directory in $this->commandr_fs (i.e. ls without the fancy bits).

_get_current_dir_contents(\?array $dir = null, boolean $full_paths = false) : \~array

Parameters

$dir

\?array

Directory (null: current directory is used)

$full_paths

boolean

Whether to use full paths

Returns

\~arrayDirectory contents (false: failure)

Return filename from a path.

_get_filename(string $filename) : string

Parameters

$filename

string

Path

Returns

stringFilename

Merge an absolute array-form path with a non-absolute array-form path, with support for "."/".

_merge_pwds(array $pwd1, array $pwd2) : array

." resolution.

Parameters

$pwd1

array

Absolute path

$pwd2

array

Non-absolute path

Returns

arrayMerged path

Fetch the current directory from a cookie, or the default.

_start_pwd() : array

Returns

arrayCurrent directory

 Properties

 

$commandr_fs

$commandr_fs 

Default

 

$current_meta

$current_meta 

Default

null
 

$current_meta_pwd

$current_meta_pwd 

Default

null
 

$pwd

$pwd 

Default