Welcome Guest, Not a member yet? Register   Sign In
File in use?
#2

[eluser]Lazos[/eluser]
To CodeIgniter people.

I do not know if is correct but please tell me asap. In the get_filenames function you use the opendir() but at the end there is no closedir().

I changed your helper and I included the closedir() before returning the data. This was the problem?

EDIT1: The same goes for unziping the file. After you call the $this->unzip->unzipAll(); just use also the $this->unzip->close(); to close the file handle.

Code:
if ( ! function_exists('get_filenames'))
{
    function get_filenames($source_dir, $include_path = FALSE, $_recursion = FALSE)
    {
        static $_filedata = array();
                
        if ($fp = @opendir($source_dir))
        {
            // reset the array and make sure $source_dir has a trailing slash on the initial call
            if ($_recursion === FALSE)
            {
                $_filedata = array();
                $source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
            }
            
            while (FALSE !== ($file = readdir($fp)))
            {
                if (@is_dir($source_dir.$file) && strncmp($file, '.', 1) !== 0)
                {
                     get_filenames($source_dir.$file.DIRECTORY_SEPARATOR, $include_path, TRUE);
                }
                elseif (strncmp($file, '.', 1) !== 0)
                {
            
                    $_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file;
                }
            }
            @closedir($fp);
            return $_filedata;
        }
        else
        {
            @closedir($fp);
            return FALSE;
        }
    }
}


Messages In This Thread
File in use? - by El Forum - 11-21-2008, 05:23 AM
File in use? - by El Forum - 11-21-2008, 05:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB