Class: File_Archive
Source Location: /File_Archive-1.3.0/File/Archive.php
Factory to access the most common File_Archive features
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Method Detail
appender [line 980]
File_Archive_Writer appender(
$URL, [
$unique = false], [
$type = null], [
$stat = array()], File_Archive_Reader
$source)
|
|
Create a writer that allows appending new files to an existing archive This function actes as appendToSource with source being the system files $URL can't be null here
Parameters:
appenderFromSource [line 926]
File_Archive_Writer appenderFromSource(
&$source, [string
$URL = null], [bool
$unique = false], [string
$type = null], [array
$stat = array()], File_Archive_Reader
$source)
|
|
Create a writer that can be used to append files to an archive inside a source If the archive can't be found in the source, it will be created If source is set to null, File_Archive::toFiles will be assumed If type is set to null, the type of the archive will be determined looking at the extension in the URL stat is the array of stat (returned by stat() PHP function of Reader getStat()) to use if the archive must be created This function allows to create or append data to nested archives. Only one archive will be created and if your creation requires creating several nested archives, a PEAR error will be returned After this call, $source will be closed and should not be used until the returned writer is closed.
Parameters:
extract [line 889]
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 517]
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 373]
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 550]
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 695]
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 656]
void predEreg(
string
$ereg)
|
|
Evaluates to true iif the name of the file follow a given regular expression
Parameters:
predEregi [line 668]
void predEregi(
string
$ereg)
|
|
Evaluates to true iif the name of the file follow a given regular expression (case insensitive version)
Parameters:
predExtension [line 631]
void predExtension(
array
$list)
|
|
Evaluates to true iif the extension of the file is in a given list
Parameters:
predFalse [line 537]
Predicate that always evaluate to false
predMaxDepth [line 619]
void predMaxDepth(
int
$depth)
|
|
Evaluates to true iif the file has less that a given number of directories in its path
Parameters:
predMIME [line 644]
void predMIME(
array
$list)
|
|
Evaluates to true iif the MIME type of the file is in a given list
Parameters:
predMinSize [line 595]
void predMinSize(
int
$size)
|
|
Evaluates to true iif the file is larger than a given size
Parameters:
predMinTime [line 607]
void predMinTime(
int
$time)
|
|
Evaluates to true iif the file has been modified after a given time
Parameters:
predNot [line 584]
void predNot(
File_Archive_Predicate
$pred)
|
|
Negate a predicate
Parameters:
predOr [line 568]
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 527]
Predicate that always evaluate to true
read [line 356]
void read(
$URL, [
$symbolic = null], [
$uncompression = 0], [
$directoryDepth = -1])
|
|
Parameters:
readArchive [line 401]
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 503]
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 454]
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 470]
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:
remove [line 1022]
void remove(
$URL
&$pred,
$URL)
|
|
Remove the files that follow a given predicate from the archive specified in $URL
Parameters:
removeDuplicates [line 1060]
void removeDuplicates(
$URL)
|
|
Remove duplicates from the archive specified in the URL
Parameters:
removeDuplicatesFromSource [line 1034]
void removeDuplicatesFromSource(
File_Archive_Reader
&$source, [
$URL = null])
|
|
Remove duplicates from a source, keeping the most recent one (or the one that has highest pos in the archive if the files have same date or no date specified)
Parameters:
removeFromSource [line 995]
void removeFromSource(
&$pred,
&$source, [
$URL = null], File_Archive_Predicate
$pred, File_Archive_Reader
$source)
|
|
Remove the files that follow a given predicate from the source If URL is null, the files will be removed from the source directly Else, URL must link to a source from which the files will be removed
Parameters:
toArchive [line 799]
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 725]
void toFiles(
[string
$baseDir = ""])
|
|
Write the files on the hard drive
Parameters:
toMail [line 712]
void toMail(
$to, array
$headers, string
$message, [Mail
$mail = null])
|
|
Send the files as a mail attachment
Parameters:
toMemory [line 744]
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 760]
void toMulti(
&$a,
&$b, File_Archive_Writer
$a,)
|
|
Duplicate the writing operation on two writers
Parameters:
toOutput [line 780]
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 749]
Documentation generated on Mon, 11 Mar 2019 14:20:00 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|