class local implements adapter_interface, stream_interface

Experimental

Properties

protected filesystem $filesystem

Filesystem component

protected string $phpbb_root_path
protected string $root_path

Absolute path to the storage folder Always finish with DIRECTORY_SEPARATOR Example:

  • /var/www/phpBB/images/avatar/upload/
  • C:\phpBB\images\avatars\upload\
protected string $path

Relative path from $phpbb_root_path to the storage folder Always finish with slash (/) character Example:

  • images/avatars/upload/

Methods

__construct(filesystem $filesystem, string $phpbb_root_path)

Constructor

void
configure(array $options)

Set adapter parameters

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)

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

void
create_dir(string $path)

Creates a directory recursively.

void
ensure_directory_exists(string $path)

Ensures that the directory of a file exists.

string
get_path(string $path)

Get the path to the file

string
get_filename(string $path)

To be used in other PR

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

int
file_size(string $path)

Get file size in bytes

float
free_space()

Get space available in bytes

Details

at line 66
__construct(filesystem $filesystem, string $phpbb_root_path)

Constructor

Parameters

filesystem $filesystem
string $phpbb_root_path

at line 75
void configure(array $options)

Set adapter parameters

Parameters

array $options

options Storage-specific options.

Return Value

void

at line 90
void put_contents(string $path, string $content)

Dumps content into a file

Parameters

string $path
string $content

Return Value

void

Exceptions

storage_exception

at line 107
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 122
bool exists(string $path)

Checks the existence of files or directories

Parameters

string $path

file/directory to check

Return Value

bool

Returns true if the file/directory exist, false otherwise.

at line 130
void delete(string $path)

Removes files or directories

Parameters

string $path

file/directory to remove

Return Value

void

Exceptions

storage_exception

at line 145
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 162
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 183
protected void create_dir(string $path)

Creates a directory recursively.

Parameters

string $path

The directory path

Return Value

void

Exceptions

storage_exception

at line 202
protected void ensure_directory_exists(string $path)

Ensures that the directory of a file exists.

Parameters

string $path

The file path

Return Value

void

Exceptions

storage_exception

at line 219
protected string get_path(string $path)

Get the path to the file

Parameters

string $path

The file path

Return Value

string

at line 233
protected string get_filename(string $path)

To be used in other PR

Parameters

string $path

The file path

Return Value

string

at line 241
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 256
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 279
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 294
float free_space()

Get space available in bytes

Return Value

float

Returns available space

Exceptions

storage_exception