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

mixed
get_adapter()

Returns an adapter instance

void
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

void
delete(string $path)

Removes files or directories

void
rename(string $path_orig, string $path_dest)

Rename a file or a directory

void
copy(string $path_orig, string $path_dest)

Copies a file

resource
read_stream(string $path)

Reads a file as a stream

void
write_stream(string $path, resource $resource)

Writes a new file using a stream

void
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

void
track_rename(string $path_orig, string $path_dest)

Rename tracked file

int
file_size(string $path)

Get file size in bytes

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 66
__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 80
string get_name()

Returns storage name

Return Value

string

at line 90
protected mixed get_adapter()

Returns an adapter instance

Return Value

mixed

at line 109
void 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.

Return Value

void

Exceptions

storage_exception

at line 131
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

storage_exception

at line 149
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 162
void delete(string $path)

Removes files or directories

Parameters

string $path

file/directory to remove

Return Value

void

Exceptions

storage_exception

at line 183
void 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

Return Value

void

Exceptions

storage_exception

at line 209
void copy(string $path_orig, string $path_dest)

Copies a file

Parameters

string $path_orig

The original filename

string $path_dest

The target filename

Return Value

void

Exceptions

storage_exception

at line 235
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

storage_exception

at line 269
void write_stream(string $path, resource $resource)

Writes a new file using a stream

Parameters

string $path

The target file

resource $resource

The resource

Return Value

void

Exceptions

storage_exception

at line 301
void 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

Return Value

void

at line 344
untrack_file(string $path)

Untrack file

Parameters

string $path

The target file

at line 366
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 388
protected void 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

Return Value

void

at line 406
int file_size(string $path)

Get file size in bytes

Parameters

string $path

The file

Return Value

int

Size in bytes.

Exceptions

storage_exception

at line 427
int get_size()

Get total storage size

Return Value

int

Size in bytes

at line 452
int get_num_files()

Get number of storage files

Return Value

int

Number of files

at line 479
float free_space()

Get space available in bytes

Return Value

float

Returns available space

Exceptions

storage_exception