class storage

Experimental

Properties

protected adapter_interface $adapter
protected driver_interface $db
protected driver_interface $cache

Cache driver

protected adapter_factory $factory
protected string $storage_name
protected string $storage_table

Methods

__construct(driver_interface $db, driver_interface $cache, adapter_factory $factory, string $storage_name, string $storage_table)

Constructor

string
get_name()

Returns storage name

get_adapter()

Returns an adapter instance

put_contents(string $path, string $content)

Dumps content into a file

string
get_contents(string $path)

Read the contents of a file

bool
exists(string $path, bool $full_check = false)

Checks the existence of files or directories

delete(string $path)

Removes files or directories

rename(string $path_orig, string $path_dest)

Rename a file or a directory

copy(string $path_orig, string $path_dest)

Copies a file

resource
read_stream(string $path)

Reads a file as a stream

write_stream(string $path, resource $resource)

Writes a new file using a stream

track_file(string $path, bool $update = false)

Track file in database

untrack_file(string $path)

Untrack file

bool
is_tracked(string $path)

Check if a file is tracked

track_rename(string $path_orig, string $path_dest)

Rename tracked file

file_info(string $path)

Get file info

string
get_link(string $path)

Get direct link

int
get_size()

Get total storage size

int
get_num_files()

Get number of storage files

float
free_space()

Get space available in bytes

Details

at line 65
__construct(driver_interface $db, driver_interface $cache, adapter_factory $factory, string $storage_name, string $storage_table)

Constructor

Parameters

driver_interface $db
driver_interface $cache
adapter_factory $factory
string $storage_name
string $storage_table

at line 79
string get_name()

Returns storage name

Return Value

string

at line 89
protected adapter_interface get_adapter()

Returns an adapter instance

Return Value

adapter_interface

at line 108
put_contents(string $path, string $content)

Dumps content into a file

Parameters

string $path

The file to be written to.

string $content

The data to write into the file.

Exceptions

exception

When the file already exists When the file cannot be written

at line 130
string get_contents(string $path)

Read the contents of a file

Parameters

string $path

The file to read

Return Value

string

Returns file contents

Exceptions

exception

When the file doesn't exist When cannot read file contents

at line 148
bool exists(string $path, bool $full_check = false)

Checks the existence of files or directories

Parameters

string $path

file/directory to check

bool $full_check

check in the filesystem too

Return Value

bool

Returns true if the file/directory exist, false otherwise

at line 161
delete(string $path)

Removes files or directories

Parameters

string $path

file/directory to remove

Exceptions

exception

When removal fails When the file doesn't exist

at line 182
rename(string $path_orig, string $path_dest)

Rename a file or a directory

Parameters

string $path_orig

The original file/direcotry

string $path_dest

The target file/directory

Exceptions

exception

When the file doesn't exist When target exists When file/directory cannot be renamed

at line 208
copy(string $path_orig, string $path_dest)

Copies a file

Parameters

string $path_orig

The original filename

string $path_dest

The target filename

Exceptions

exception

When the file doesn't exist When target exists When the file cannot be copied

at line 234
resource read_stream(string $path)

Reads a file as a stream

Parameters

string $path

File to read

Return Value

resource

Returns a file pointer

Exceptions

exception

When the file doesn't exist When unable to open file

at line 268
write_stream(string $path, resource $resource)

Writes a new file using a stream

Parameters

string $path

The target file

resource $resource

The resource

Exceptions

exception

When the file exist When target file cannot be created

at line 300
track_file(string $path, bool $update = false)

Track file in database

Parameters

string $path

The target file

bool $update

Update file size when already tracked

at line 348
untrack_file(string $path)

Untrack file

Parameters

string $path

The target file

at line 370
bool is_tracked(string $path)

Check if a file is tracked

Parameters

string $path

The file

Return Value

bool

True if file is tracked

at line 392
protected track_rename(string $path_orig, string $path_dest)

Rename tracked file

Parameters

string $path_orig

The original file/direcotry

string $path_dest

The target file/directory

at line 411
file_info file_info(string $path)

Get file info

Parameters

string $path

The file

Return Value

file_info

Returns file_info object

Exceptions

not_implemented

When the adapter doesnt implement the method When the file doesn't exist

Get direct link

Parameters

string $path

The file

Return Value

string

Returns link.

at line 439
int get_size()

Get total storage size

Return Value

int

Size in bytes

at line 464
int get_num_files()

Get number of storage files

Return Value

int

Number of files

at line 491
float free_space()

Get space available in bytes

Return Value

float

Returns available space

Exceptions

exception

When unable to retrieve available storage space