Class: File_Archive
Source Location: /File_Archive-1.2.0/File/Archive.php
Factory to access the most common File_Archive features
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Method Detail
extract [line 875]
null extract(
&$source,
&$dest, [bool
$autoClose = true], [int
$bufferSize = 8192], File_Archive_Reader
$source, File_Archive_Writer
$dest)
|
|
File_Archive::extract($source, $dest) is equivalent to $source->extract($dest) If $source is a PEAR error, the error will be returned It is thus easier to use this function than $source->extract, since it reduces the number of error checking and doesn't force you to define a variable $source
Parameters:
filter [line 503]
void filter(
File_Archive_Predicate
$predicate, File_Archive_Reader
$source)
|
|
Removes from a source the files that do not follow a given predicat
Parameters:
isKnownExtension [line 359]
bool isKnownExtension(
string
$extension)
|
|
Check if a file with a specific extension can be read as an archive with File_Archive::read* This function is case sensitive.
Parameters:
predAnd [line 536]
void predAnd(
File_Archive_Predicate
0)
|
|
Predicate that evaluates to the logical AND of the parameters You can add other predicates thanks to the File_Archive_Predicate_And::addPredicate() function
Parameters:
predCustom [line 681]
void predCustom(
string
$expression)
|
|
Custom predicate built by supplying a string expression Here are different ways to create a predicate that keeps only files with names shorter than 100 chars <sample> File_Archive::predCustom("return strlen($name)<100;") File_Archive::predCustom("strlen($name)<100;") File_Archive::predCustom("strlen($name)<100") File_Archive::predCustom("strlen($source->getFilename())<100") </sample>
Parameters:
predEreg [line 642]
void predEreg(
string
$ereg)
|
|
Evaluates to true iif the name of the file follow a given regular expression
Parameters:
predEregi [line 654]
void predEregi(
string
$ereg)
|
|
Evaluates to true iif the name of the file follow a given regular expression (case insensitive version)
Parameters:
predExtension [line 617]
void predExtension(
array
$list)
|
|
Evaluates to true iif the extension of the file is in a given list
Parameters:
predFalse [line 523]
Predicate that always evaluate to false
predMaxDepth [line 605]
void predMaxDepth(
int
$depth)
|
|
Evaluates to true iif the file has less that a given number of directories in its path
Parameters:
predMIME [line 630]
void predMIME(
array
$list)
|
|
Evaluates to true iif the MIME type of the file is in a given list
Parameters:
predMinSize [line 581]
void predMinSize(
int
$size)
|
|
Evaluates to true iif the file is larger than a given size
Parameters:
predMinTime [line 593]
void predMinTime(
int
$time)
|
|
Evaluates to true iif the file has been modified after a given time
Parameters:
predNot [line 570]
void predNot(
File_Archive_Predicate
$pred)
|
|
Negate a predicate
Parameters:
predOr [line 554]
void predOr(
File_Archive_Predicate
0)
|
|
Predicate that evaluates to the logical OR of the parameters You can add other predicates thanks to the File_Archive_Predicate_Or::addPredicate() function
Parameters:
predTrue [line 513]
Predicate that always evaluate to true
read [line 342]
void read(
$URL, [
$symbolic = null], [
$uncompression = 0], [
$directoryDepth = -1])
|
|
Parameters:
readArchive [line 387]
A readArchive(
string
$extension,
&$source, [bool
$sourceOpened = false], File_Archive_Reader
$source)
|
|
Create a reader that will read the single file source $source as a specific archive
Parameters:
readConcat [line 489]
void readConcat(
&$source, string
$filename, [array
$stat = array()], [string
$mime = null], File_Archive_Reader
$source)
|
|
Make the files of a source appear as one large file whose content is the concatenation of the content of all the files
Parameters:
readMemory [line 440]
void readMemory(
string
$memory, string
$filename, [array
$stat = array()], [string
$mime = null])
|
|
Contains only one file with data read from a memory buffer
Parameters:
readMulti [line 456]
void readMulti(
[array
$sources = array()])
|
|
Contains several other sources. Take care the sources don't have several files with the same filename. The sources are given as a parameter, or can be added thanks to the reader addSource method
Parameters:
readSource [line 159]
void readSource(
&$source,
$URL, [
$symbolic = null], [
$uncompression = 0], [
$directoryDepth = -1])
|
|
Create a reader to read the URL $URL. If the URL is a directory, it will recursively read that directory. If $uncompressionLevel is not null, the archives (files with extension tar, zip, gz or tgz) will be considered as directories (up to a depth of $uncompressionLevel if $uncompressionLevel > 0). The reader will only read files with a directory depth of $directoryDepth. It reader will replace the given URL ($URL) with $symbolic in the public filenames The default symbolic name is the last filename in the URL (or '' for directories) Examples: Considere the following file system a.txt
b.tar (archive that contains the following files)
c.txt
d.tgz (archive that contains the following files)
e.txt
dir1/
f.txt
dir2/
g.txt
dir3/
h.tar (archive that contains the following files)
i.txtread('.') will return a reader that gives access to following files (recursively read current dir): a.txt
b.tar
dir2/g.txt
dir2/dir3/h.tar read('.', 'myBaseDir') will return the following reader: myBaseDir/a.txt
myBaseDir/b.tar
myBaseDir/dir2/g.txt
myBaseDir/dir2/dir3/h.tar read('.', '', -1) will return the following reader (uncompress everything) a.txt
b.tar/c.txt
b.tar/d.tgz/e.txt
b.tar/d.tgz/dir1/f.txt
dir2/g.txt
dir2/dir3/h.tar/i.txt read('.', '', 1) will uncompress only one level (so d.tgz will not be uncompressed): a.txt
b.tar/c.txt
b.tar/d.tgz
dir2/g.txt
dir2/dir3/h.tar/i.txt read('.', '', 0, 0) will not recurse into subdirectories a.txt
b.tar read('.', '', 0, 1) will recurse only one level in subdirectories a.txt
b.tar
dir2/g.txt read('.', '', -1, 2) will uncompress everything and recurse in only 2 levels in subdirectories or archives a.txt
b.tar/c.txt
b.tar/d.tgz/e.txt
dir2/g.txt The recursion level is determined by the real path, not the symbolic one. So read('.', 'myBaseDir', -1, 2) will result to the same files: myBaseDir/a.txt
myBaseDir/b.tar/c.txt
myBaseDir/b.tar/d.tgz/e.txt (accepted because the real depth is 2)
myBaseDir/dir2/g.txt Use readSource to do the same thing, reading from a specified reader instead of reading from the system files To read a single file, you can do read('a.txt', 'public_name.txt') If no public name is provided, the default one is the name of the file read('dir2/g.txt') contains the single file named 'g.txt' read('b.tar/c.txt') contains the single file named 'c.txt' Note: This function uncompress files reading their extension The compressed files must have a tar, zip, gz or tgz extension Since it is impossible for some URLs to use is_dir or is_file, this function may not work with URLs containing folders which name ends with such an extension
Parameters:
toArchive [line 785]
void toArchive(
string
$filename,
&$innerWriter, [string
$type = null], [array
$stat = array()], [bool
$autoClose = true], File_Archive_Writer
$innerWriter)
|
|
Compress the data to a tar, gz, tar/gz or zip format
Parameters:
toFiles [line 711]
void toFiles(
[string
$baseDir = ""])
|
|
Write the files on the hard drive
Parameters:
toMail [line 698]
void toMail(
$to, array
$headers, string
$message, [Mail
$mail = null])
|
|
Send the files as a mail attachment
Parameters:
toMemory [line 730]
void toMemory(
out
$data)
|
|
Send the content of the files to a memory buffer toMemory returns a writer where the data will be written. In this case, the data is accessible using the getData member toVariable returns a writer that will write into the given variable
Parameters:
toMulti [line 746]
void toMulti(
&$a,
&$b, File_Archive_Writer
$a,)
|
|
Duplicate the writing operation on two writers
Parameters:
toOutput [line 766]
void toOutput(
[bool
$sendHeaders = true])
|
|
Send the content of the files to the standard output (so to the client for a website)
Parameters:
toVariable [line 735]
Documentation generated on Mon, 11 Mar 2019 14:19:43 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|