noalyss  Version-6.7.2
Public Member Functions
Zip_Extended Class Reference
Inheritance diagram for Zip_Extended:
ZipArchive

Public Member Functions

 add_recurse_folder ($dir, $zipdir='')
 Function to recursively add a directory, sub-directories and files to a zip archive.

Detailed Description

Definition at line 26 of file class_zip_extended.php.


Member Function Documentation

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 36 of file class_zip_extended.php.

References $file.

  {
    if (is_dir($dir)) 
      {
        if ($dh = opendir($dir)) 
          {
            // Loop through all the files
            $filenct = 0;
            while (($file = readdir($dh)) !== false) 
              {
                //If it's a folder, run the function again!
                if(!is_file($dir . $file))
                  {
                    // Skip parent and root directories
                    if( ($file !== ".") && ($file !== ".."))
                      {
                        $this->add_recurse_folder($dir . $file . '/',  $zipdir . $file . '/');
                      }
                  }
                else
                  {
                    // Add the files
                    $this->addFile($dir . $file, $zipdir . $file);
                    $filenct +=1;
                  }
              }
            //Add the directory when folder was empty
            if( (!empty($zipdir)) && ($filenct==0)) 
              {
                // remove directory separator before addEmptyDir      
                // otherwhisen create double folder in zip
                $this->addEmptyDir(substr($zipdir, 0, -1));
              } 
          }
      }
  }

The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations