Re: Re: [PHP-DEV] new FTP function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 18, 2013 at 9:26 PM, tamouse mailing lists
<tamouse.lists@xxxxxxxxx> wrote:
> On Fri, Jan 18, 2013 at 9:43 AM, Daniel Brown <danbrown@xxxxxxx> wrote:
>> On Fri, Jan 18, 2013 at 10:33 AM, KISE <wowkise@xxxxxxxxx> wrote:
>>> Paul Dragoonis,
>>>
>>> Actually it wont work i did tried it before, if the dir end with / it will
>>> list the directories inside the path you gave it and if it doesn't have any
>>> directories it will return false since there is no directories to return.
>>>
>>> you have to take out the last / and then remove the directory in question
>>> and list the files in the parent directory and check if the dir exists
>>> otherwise it will return false, i spent 3hrs yesterday thinking why its
>>> returning false even though the directory exists.
>>
>>     The discussion is now getting more into the general coding realm
>> than internals, so let's move it over there in case anyone wants to
>> mention something like:
>>
>> function ftp_dir_exists($conn, $currentDir) {
>>         $currentDir = (substr($currentDir,-1,1) == '/') ?
>> substr($currentDir,0,-1) : $currentDir;
>>         $list  = ftp_nlist($conn, '-dF '. $currentDir);
>>         return in_array($currentDir, $list);
>> }
>
>
> Haven't played with ftp functions at all, but wondering what if you
> gave it dirname($currentDir) instead of $currentDir? (Still have to do
> the trailing '/'-ectomy)
>
>    $list = ftp_nlist($conn, dirname($currentDir));
>
> untested, just a thought.

Although on further thought, if $currentDir actually points to a
non-directory, that will still pass, won't it. Might have to go with
ftp_rawlist and parse it out to ensure it is a directory... Check the
first character of each line to see if it's 'd', then the file name
will be the last field in the line.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux