Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_files\archive_writer Class Reference

Each file archive type must extend this class. More...

Inheritance diagram for core_files\archive_writer:
core_files\local\archive_writer\zip_writer

Public Member Functions

 add_file_from_filepath (string $name, string $path)
 Adds a file from a file path.
 
 add_file_from_stored_file (string $name, stored_file $file)
 Adds a stored_file to archive.
 
 add_file_from_stream (string $name, $stream)
 Adds a file from a stream.
 
 add_file_from_string (string $name, string $data)
 Adds a file from a string.
 
 finish ()
 Finish writing the zip footer.
 
 sanitise_filepath (string $filepath)
 Sanitise the file path, removing any unsuitable characters.
 

Static Public Member Functions

static get_file_writer (string $filepath, string $type)
 Returns the file writer.
 
static get_stream_writer (string $filename, string $type)
 Returns the stream writer.
 

Public Attributes

const ZIP_WRITER = 'zip_writer'
 The zip writer class.
 

Protected Member Functions

 __construct ()
 The archive_writer Constructor.
 

Static Protected Member Functions

static get_classname_for_type (string $type)
 Returns the class name for the type that was provided in get_file_writer().
 

Detailed Description

Each file archive type must extend this class.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ add_file_from_filepath()

core_files\archive_writer::add_file_from_filepath ( string $name,
string $path )
abstract

Adds a file from a file path.

Parameters
string$nameThe path of file in archive (including directory).
string$pathThe path to file on disk (note: paths should be encoded using UNIX-style forward slashes – e.g '/path/to/some/file').

Reimplemented in core_files\local\archive_writer\zip_writer.

◆ add_file_from_stored_file()

core_files\archive_writer::add_file_from_stored_file ( string $name,
stored_file $file )
abstract

Adds a stored_file to archive.

Parameters
string$nameThe path of file in archive (including directory).
stored_file$file

Reimplemented in core_files\local\archive_writer\zip_writer.

◆ add_file_from_stream()

core_files\archive_writer::add_file_from_stream ( string $name,
$stream )
abstract

Adds a file from a stream.

Parameters
string$nameThe path of file in archive (including directory).
resource$streamThe contents of file as a stream resource

Reimplemented in core_files\local\archive_writer\zip_writer.

◆ add_file_from_string()

core_files\archive_writer::add_file_from_string ( string $name,
string $data )
abstract

Adds a file from a string.

Parameters
string$nameThe path of file in archive (including directory).
string$dataThe contents of file

Reimplemented in core_files\local\archive_writer\zip_writer.

◆ finish()

core_files\archive_writer::finish ( )
abstract

Finish writing the zip footer.

Reimplemented in core_files\local\archive_writer\zip_writer.

◆ get_classname_for_type()

static core_files\archive_writer::get_classname_for_type ( string $type)
staticprotected

Returns the class name for the type that was provided in get_file_writer().

Parameters
string$type
Return values
string

◆ get_file_writer()

static core_files\archive_writer::get_file_writer ( string $filepath,
string $type )
static

Returns the file writer.

Parameters
string$filepath
string$type
Return values
file_writer_interface

◆ get_stream_writer()

static core_files\archive_writer::get_stream_writer ( string $filename,
string $type )
static

Returns the stream writer.

Parameters
string$filename
string$type
Return values
stream_writer_interface

◆ sanitise_filepath()

core_files\archive_writer::sanitise_filepath ( string $filepath)

Sanitise the file path, removing any unsuitable characters.

Parameters
string$filepath
Return values
string

Reimplemented in core_files\local\archive_writer\zip_writer.


The documentation for this class was generated from the following file: