phpBB API Documentation
Class

phpbb\storage\storage

class storage

Methods

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

Constructor

string get_name()

Returns storage name

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

file_info 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
public __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
public string get_name()

Returns storage name

Return Value

string

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

Dumps content into a file

Parameters

string $path path The file to be written to.
string $content content The data to write into the file.

Exceptions

exception When the file already exists When the file cannot be written

at line 130
public 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
public 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
public 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
public 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
public 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
public 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
public 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
public 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
public untrack_file(string $path)

Untrack file

Parameters

string $path The target file

at line 370
public 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 411
public 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
public int get_size()

Get total storage size

Return Value

int Size in bytes

at line 464
public int get_num_files()

Get number of storage files

Return Value

int Number of files

at line 491
public float free_space()

Get space available in bytes

Return Value

float Returns available space

Exceptions

exception When unable to retrieve available storage space