extends the Zip object
More...
|
| add_file_pattern ( $p_folder, $p_pattern) |
| add file to the current file from a folder matching the pattern $p_pattern More...
|
|
| add_recurse_folder ($dir, $zipdir='') |
| Function to recursively add a directory, sub-directories and files to a zip archive. More...
|
|
extends the Zip object
Definition at line 31 of file zip_extended.class.php.
◆ add_file_pattern()
Zip_Extended::add_file_pattern |
( |
|
$p_folder, |
|
|
|
$p_pattern |
|
) |
| |
add file to the current file from a folder matching the pattern $p_pattern
- Parameters
-
$p_folder | string folder where are the file to add |
$p_pattern | string pattern syntax preg_match |
- Returns
- int number of files added
- Exceptions
-
throw | an exception err message is ERR-EZ95 if file cannot be added |
Definition at line 85 of file zip_extended.class.php.
85 :int
86 {
87 if (!is_dir($p_folder)) {
88 throw new \Exception("ERR-ZE87");
89
90 }
91 $dir=opendir($p_folder);
92 if(
$dir==
false)
throw new \Exception(
"ERR-ZE90");
93 $added=0;
94 while( ($entry=readdir(
$dir)) !=
false) {
95 if ( preg_match($p_pattern, $entry)) {
96 if ( ! $this->addFile($p_folder . "/" . $entry,$entry) )
97 throw new \Exception("ERR-EZ95 : cannot add $p_folder/$entry");
98 $added++;
99 }
100 }
101 return $added;
102 }
References $dir.
◆ add_recurse_folder()
Zip_Extended::add_recurse_folder |
( |
|
$dir, |
|
|
|
$zipdir = '' |
|
) |
| |
Function to recursively add a directory, sub-directories and files to a zip archive.
- Note
- ODS format expect unix / instead of DIRECTORY_SEPARATOR otherwise, new file can not be read by OpenOffice see PHP Bug #48763 ZipArchive produces corrupt OpenOffice.org files
Definition at line 41 of file zip_extended.class.php.
42 {
44 {
45 if ($dh = opendir(
$dir))
46 {
47
48 $filenct = 0;
49 while ((
$file = readdir($dh)) !==
false)
50 {
51
53 {
54
56 {
58 }
59 }
60 else
61 {
62
64 $filenct +=1;
65 }
66 }
67
68 if( (!empty($zipdir)) && ($filenct==0))
69 {
70
71
72 $this->addEmptyDir(substr($zipdir, 0, -1));
73 }
74 }
75 }
76 }
add_recurse_folder($dir, $zipdir='')
Function to recursively add a directory, sub-directories and files to a zip archive.
References $dir, $file, and add_recurse_folder().
Referenced by add_recurse_folder().
The documentation for this class was generated from the following file: