Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core_files\local\archive_writer\zip_writer Class Reference

Class used for creating ZIP archives. More...

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

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.
 
 get_path_to_zip ()
 Get the path of the zip.
 
 sanitise_filepath (string $filepath)
 Sanitise the file path, removing any unsuitable characters.
 

Static Public Member Functions

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

Public Attributes

const ZIP_WRITER = 'zip_writer'
 The zip writer class.
 

Protected Member Functions

 __construct (ZipStream $archive)
 The zip_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

Class used for creating ZIP archives.

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

Constructor & Destructor Documentation

◆ __construct()

core_files\local\archive_writer\zip_writer::__construct ( ZipStream $archive)
protected

The zip_writer constructor.

Parameters
ZipStream$archive

Member Function Documentation

◆ add_file_from_filepath()

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

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 from core_files\archive_writer.

◆ add_file_from_stored_file()

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

Adds a stored_file to archive.

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

Reimplemented from core_files\archive_writer.

◆ add_file_from_stream()

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

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 from core_files\archive_writer.

◆ add_file_from_string()

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

Adds a file from a string.

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

Reimplemented from core_files\archive_writer.

◆ file_instance()

static core_files\local\archive_writer\zip_writer::file_instance ( string $filename)
static

Return the file instance.

Parameters
string$filename
Return values
static

Implements core_files\local\archive_writer\file_writer_interface.

◆ finish()

core_files\local\archive_writer\zip_writer::finish ( )

Finish writing the zip footer.

Reimplemented from core_files\archive_writer.

◆ get_classname_for_type()

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

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 )
staticinherited

Returns the file writer.

Parameters
string$filepath
string$type
Return values
file_writer_interface

◆ get_path_to_zip()

core_files\local\archive_writer\zip_writer::get_path_to_zip ( )

Get the path of the zip.

Return values
string

Implements core_files\local\archive_writer\file_writer_interface.

◆ get_stream_writer()

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

Returns the stream writer.

Parameters
string$filename
string$type
Return values
stream_writer_interface

◆ sanitise_filepath()

core_files\archive_writer::sanitise_filepath ( string $filepath)
inherited

Sanitise the file path, removing any unsuitable characters.

Parameters
string$filepath
Return values
string

◆ stream_instance()

static core_files\local\archive_writer\zip_writer::stream_instance ( string $filename)
static

Return the stream instance.

Parameters
string$filename
Return values
static

Implements core_files\local\archive_writer\stream_writer_interface.


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