class local implements adapter_interface, stream_interface

Experimental

Properties

protected filesystem $filesystem

Filesystem component

protected FastImageSize $imagesize

FastImageSize

protected guesser $mimetype_guesser

Mimetype Guesser 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/
protected $subfolders
protected $dir_depth

Methods

__construct(filesystem $filesystem, FastImageSize $imagesize, guesser $mimetype_guesser, 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.

void
remove_empty_dirs(string $path)

Removes the directory tree ascending until it finds a non empty directory.

string
get_path(string $path)

Get the path to the file, appending subdirectories for directory depth if $dir_depth > 0.

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

array
file_size(string $path)

Get file size

array
file_mimetype(string $path)

Get file mimetype

array
image_dimensions(string $path)

Get image dimensions

array
file_image_width(string $path)

Get image width

array
file_image_height(string $path)

Get image height

string
get_link(string $path)

Get direct link

float
free_space()

Get space available in bytes

Details

at line 107
__construct(filesystem $filesystem, FastImageSize $imagesize, guesser $mimetype_guesser, string $phpbb_root_path)

Constructor

Parameters

filesystem $filesystem
FastImageSize $imagesize
guesser $mimetype_guesser
string $phpbb_root_path

at line 118
void configure(array $options)

Set adapter parameters

Parameters

array $options

Return Value

void

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

Dumps content into a file

Parameters

string $path
string $content

Return Value

void

Exceptions

exception

When the file cannot be written

at line 151
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 cannot read file contents

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

Removes files or directories

Parameters

string $path

file/directory to remove

Return Value

void

Exceptions

exception

When removal fails.

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

exception

When file/directory cannot be renamed

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

exception

When the file cannot be copied

at line 231
protected void create_dir(string $path)

Creates a directory recursively.

Parameters

string $path

The directory path

Return Value

void

Exceptions

exception

On any directory creation failure

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

exception

On any directory creation failure

at line 266
protected void remove_empty_dirs(string $path)

Removes the directory tree ascending until it finds a non empty directory.

Parameters

string $path

The file path

Return Value

void

at line 291
protected string get_path(string $path)

Get the path to the file, appending subdirectories for directory depth if $dir_depth > 0.

Parameters

string $path

The file path

Return Value

string

at line 318
protected string get_filename(string $path)

To be used in other PR

Parameters

string $path

The file path

Return Value

string

at line 326
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 unable to open file

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

exception

When target file exists When target file cannot be created

at line 372
array file_size(string $path)

Get file size

Parameters

string $path

The file

Return Value

array

Properties

Exceptions

exception

When cannot get size

exception

When cannot get size

at line 391
array file_mimetype(string $path)

Get file mimetype

Parameters

string $path

The file

Return Value

array

Properties

at line 403
protected array image_dimensions(string $path)

Get image dimensions

Parameters

string $path

The file

Return Value

array

Properties

at line 424
array file_image_width(string $path)

Get image width

Parameters

string $path

The file

Return Value

array

Properties

at line 436
array file_image_height(string $path)

Get image height

Parameters

string $path

The file

Return Value

array

Properties

Get direct link

Parameters

string $path

The file

Return Value

string

Returns link.

at line 452
float free_space()

Get space available in bytes

Return Value

float

Returns available space

Exceptions

exception

When unable to retrieve available storage space