On Wed, Apr 25, 2001 at 09:33:47AM +0200, Andi Gutmans wrote:
> OK. I commited one more patch which should fix filetype() and lstat(). I'd 
> appreciate it if you can take a minute and just make sure they work now and 
> that I didn't cause any problems with the fixed is_link().
> It's not my code so that's why I'm messing with it slowly. It had some 
> dependencies inside the code and I wanted to make sure I keep it consistent.
> 
> Andi
> 

Looks perfect.. lstat() and filetype() both work fine on the broken
symlink.. as does is_link().  I'd call it fixed.  ;)

file_exists() still 'fails' on a broken symlink, but perhaps it should.
That could get a little on the philosophical side.

Thanks alot for the quick fix!

Jeremy

Just for the record.. here's the code.. and then its output.
--code
function link_func_test ($file)
{
     if ( is_link ($file)) { print ("is_link() passed\n"); }
     else { print ("is_link() failed\n"); }

     if (($link_target = readlink ($file))) {
          print ("readlink() passed:  $link_target\n");
     }
     else { print ("readlink() failed\n"); }

     if (($temp_filetype = filetype ($file))) {
          print ("filetype() passed:  $temp_filetype\n");
     }
     else { print ("filetype() failed\n"); }

     if (($temp_lstat = lstat ($file))) {
          print ("lstat() passed:\n\n"); print_r ($temp_lstat);
     }
     else { print ("lstat() failed\n"); }

     if (file_exists ($file)) { print ("file_exists() passed:\n"); }
     else { print ("file_exists() failed\n"); }
}

$file = '/tmp/test-link-func';

@ unlink ($file);
if (symlink ('/bin/false', $file)) {
     link_func_test ($file);
} else { print ("Good symlink failed\n"); }

@ unlink ($file);
if (symlink ('/this/file/does/not/exist', $file)) {
     link_func_test ($file);
} else { print ("Bad symlink failed\n"); }
--end

--output
:(01:39am ~/php): ./fs-test.php
is_link() passed
readlink() passed:  /bin/false
filetype() passed:  link
lstat() passed:

Array
(
    [0] => 770
    [1] => 749
    [2] => 41471
    [3] => 1
    [4] => 0
    [5] => 0
    [6] => 0
    [7] => 10
    [8] => 988180923
    [9] => 988180923
    [10] => 988180923
    [11] => 4096
    [12] => 1
)
file_exists() passed:

is_link() passed
readlink() passed:  /this/file/does/not/exist
filetype() passed:  link
lstat() passed:

Array
(
    [0] => 770
    [1] => 749
    [2] => 41471
    [3] => 1
    [4] => 0
    [5] => 0
    [6] => 0
    [7] => 25
    [8] => 988180923
    [9] => 988180923
    [10] => 988180923
    [11] => 4096
    [12] => 1
)
file_exists() failed
--end

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to