Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
file_archive Class Reference

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

Inheritance diagram for file_archive:
zip_archive

Public Member Functions

 add_directory ($localname)
 Add empty directory into archive.
 
 add_file_from_pathname ($localname, $pathname)
 Add file into archive.
 
 add_file_from_string ($localname, $contents)
 Add content of string into archive.
 
 close ()
 Close archive.
 
 count ()
 Returns number of files in archive.
 
 get_info ($index)
 Returns file information.
 
 get_stream ($index)
 Returns file stream for reading of content.
 
 list_files ()
 Returns array of info about all files in archive.
 
 open ($archivepathname, $mode=file_archive::CREATE, $encoding='utf-8')
 Open or create archive (depending on $mode).
 

Public Attributes

const CREATE = 2
 Open archive if exists, create if does not.
 
const OPEN = 1
 Open archive if exists, fail if does not exist.
 
const OVERWRITE = 4
 Always create new archive.
 

Protected Member Functions

 mangle_pathname ($localname)
 Tries to convert $localname into another encoding, please note that it may fail really badly.
 
 unmangle_pathname ($localname)
 Tries to convert $localname into utf-8 please note that it may fail really badly.
 

Protected Attributes

string $encoding = 'utf-8'
 Encoding of file names - windows usually expects DOS single-byte charset.
 

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_directory()

file_archive::add_directory ( $localname)
abstract

Add empty directory into archive.

Parameters
string$localnamename of file in archive
Return values
boolsuccess

Reimplemented in zip_archive.

◆ add_file_from_pathname()

file_archive::add_file_from_pathname ( $localname,
$pathname )
abstract

Add file into archive.

Parameters
string$localnamename of file in archive
string$pathnamelocation of file
Return values
boolsuccess

Reimplemented in zip_archive.

◆ add_file_from_string()

file_archive::add_file_from_string ( $localname,
$contents )
abstract

Add content of string into archive.

Parameters
string$localnamename of file in archive
string$contentscontents
Return values
boolsuccess

Reimplemented in zip_archive.

◆ close()

file_archive::close ( )
abstract

Close archive.

Return values
boolsuccess

Reimplemented in zip_archive.

◆ count()

file_archive::count ( )
abstract

Returns number of files in archive.

Return values
intnumber of files

Reimplemented in zip_archive.

◆ get_info()

file_archive::get_info ( $index)
abstract

Returns file information.

Parameters
int$indexindex of file
Return values
stdClass|boolobject or false if error

Reimplemented in zip_archive.

◆ get_stream()

file_archive::get_stream ( $index)
abstract

Returns file stream for reading of content.

Parameters
int$indexindex of file
Return values
stream|boolstream or false if error

Reimplemented in zip_archive.

◆ list_files()

file_archive::list_files ( )
abstract

Returns array of info about all files in archive.

Return values
arrayof file infos

Reimplemented in zip_archive.

◆ mangle_pathname()

file_archive::mangle_pathname ( $localname)
protected

Tries to convert $localname into another encoding, please note that it may fail really badly.

Parameters
string$localnamename of file in utf-8 encoding
Return values
string

Reimplemented in zip_archive.

◆ open()

file_archive::open ( $archivepathname,
$mode = file_archive::CREATE,
$encoding = 'utf-8' )
abstract

Open or create archive (depending on $mode).

Parameters
string$archivepathnamearchive path name
int$modeOPEN, CREATE or OVERWRITE constant
string$encodingarchive local paths encoding
Return values
boolsuccess

Reimplemented in zip_archive.

◆ unmangle_pathname()

file_archive::unmangle_pathname ( $localname)
protected

Tries to convert $localname into utf-8 please note that it may fail really badly.

The resulting file name is cleaned.

Parameters
string$localnamename of file in $this->encoding
Return values
stringin utf-8

Reimplemented in zip_archive.


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