From:             wowkise at gmail dot com
Operating system: Linux
PHP version:      Irrelevant
Package:          FTP related
Bug Type:         Feature/Change Request
Bug description:ftp_dir_exists()

Description:
------------
I think PHP needs proper way to check if the FTP directory exists, right
now there is no correct way to do it other then using ftp_chdir/is_dir and
check the results which produce E_WARNING if the directory doesn't exists.

there is also is_dir() function which require that you re-authenticate just
to check if the directory exists and if you have to check multiple
directories you have to re-authenticate each time.

i hacked this function in "test script" just to bypass the E_WARNING 

Test script:
---------------
function dir_exists2($conn, $dir) {
    $orginal = $dir;
    if ( !$conn )
        return false;

    if ( substr($dir, -1) === '/' )
        $dir = substr($dir, 0, strlen($dir)-1);

    $dir    = substr($dir, 0, strlen($dir)-strlen(strrchr($dir,'/')));

    $res  = ftp_nlist($conn, '-dF '. $dir);
    if ( isset($res) AND is_array($res) ) {
            foreach ($res as $key => $value) {
                if ($value === $orginal)
                    return true;
            }
        }
        return false;
    }

Expected result:
----------------
true if directory exists and false if it does not exists.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=64024&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64024&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64024&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=64024&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=64024&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=64024&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=64024&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=64024&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=64024&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=64024&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=64024&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=64024&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=64024&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=64024&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64024&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=64024&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=64024&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=64024&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64024&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=64024&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64024&r=mysqlcfg

Reply via email to