Welcome Guest, Not a member yet? Register   Sign In
ZIP a specific directory.
#15

[eluser]leighmarble[/eluser]
Well, I tried that out, but it is still grabbing the parent directories. Bummer!

I think I had tried that idea last week too, which is why I then tried my hand at the (PHP 5-only) RecursiveIteratorIterator approach I posted above. Using that approach, you can track the directory depth with the getDepth method. Unfortunately, this resulted in Zip files that expanded to ".zip.cpgz" files. Why, I don't know, but that's clearly no good either.

FYI, this is what I changed read_dir to:

Code:
function read_dir($path)
    {    
        if ($fp = @opendir($path))
        {
            while (FALSE !== ($file = readdir($fp)))
            {
                if (@is_dir($path.$file) && substr($file, 0, 1) != '.' && substr($file, 0, 2) != '..')
                {                    
                    $this->read_dir($path.$file."/");
                }
                elseif (substr($file, 0, 1) != "." && substr($file, 0, 2) != '..')
                {
                    if (FALSE !== ($data = file_get_contents($path.$file)))
                    {                        
                        $this->add_data(str_replace("\\", "/", $path).$file, $data);
                    }
                }
            }
            return TRUE;
        }
    }
I'm not much of a code ninja... would love it if a real pro here would work over this code for a few minutes!

thanks,
Leigh


Messages In This Thread
ZIP a specific directory. - by El Forum - 11-21-2008, 02:08 PM
ZIP a specific directory. - by El Forum - 02-24-2009, 07:50 PM
ZIP a specific directory. - by El Forum - 02-24-2009, 11:05 PM
ZIP a specific directory. - by El Forum - 03-03-2009, 02:27 PM
ZIP a specific directory. - by El Forum - 03-03-2009, 03:46 PM
ZIP a specific directory. - by El Forum - 03-03-2009, 04:00 PM
ZIP a specific directory. - by El Forum - 03-03-2009, 04:07 PM
ZIP a specific directory. - by El Forum - 03-03-2009, 04:25 PM
ZIP a specific directory. - by El Forum - 03-03-2009, 05:39 PM
ZIP a specific directory. - by El Forum - 03-03-2009, 06:00 PM
ZIP a specific directory. - by El Forum - 03-03-2009, 06:32 PM
ZIP a specific directory. - by El Forum - 03-03-2009, 06:43 PM
ZIP a specific directory. - by El Forum - 03-03-2009, 06:51 PM
ZIP a specific directory. - by El Forum - 03-03-2009, 07:21 PM
ZIP a specific directory. - by El Forum - 03-03-2009, 07:44 PM
ZIP a specific directory. - by El Forum - 03-03-2009, 07:54 PM
ZIP a specific directory. - by El Forum - 03-04-2009, 12:28 PM
ZIP a specific directory. - by El Forum - 03-04-2009, 01:00 PM
ZIP a specific directory. - by El Forum - 03-04-2009, 03:23 PM
ZIP a specific directory. - by El Forum - 03-04-2009, 03:30 PM
ZIP a specific directory. - by El Forum - 03-04-2009, 03:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB