private function scanDirectory($directory, $recursive)
    {
        if (!$results = @scandir($this->getUrl($directory))) {
            return false;
        }

        $files       = array();
        $directories = array();

        foreach ($results as $result) {
            if (in_array($result, array('.', '..'))) {
                continue;
            }

            $filename = sprintf('%s/%s', $directory, $result);

            if (false === @scandir($this->getUrl($filename))) {
                $files[] = $filename;
            } else {
                $directories[] = $filename;

                if ($recursive) {
                    $children    = $this->scanDirectory($filename, $recursive);
                    if (is_array($children)) {
                        $files       = array_merge($files, $children[0]);
                        $directories = array_merge($directories, $children[1]);
                    }
                }
            }
        }

        return array($files, $directories);
    }