Re: is_link() behavior

From: Date: Wed, 25 Apr 2001 05:22:03 +0000
Subject: Re: is_link() behavior
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-52342@lists.php.net to get a copy of this message
Hi, I just commited a patch which also cleaned up some other stuff (although it could still use some fixing up). Please check the latest CVS to see if it works now. Also can you please check the lstat() command? I think it has the same problem (I didn't fix it because I want to be sure) and I think filetype() might also not work correctly on links which aren't pointing to anything (at least not give all the right information). Andi At 04:51 PM 4/24/2001 -0500, J. Jones wrote:
On Tue, Apr 24, 2001 at 10:50:36AM +0200, Andi Gutmans wrote: It definitely seems as if the logic in the code (filestat.c) is kind of screwed up. If no one has time to look at it I can try and take a look at it later on. Andi At 01:35 AM 4/24/2001 -0500, J. Jones wrote:
Forgive me for my ignorance, but I've noticed some unwanted behavior (IMO, at least) with the is_link() function. Given the simple code..
        if ( is_link ("/tmp/this_is_a_symlink") )
                print ("Success\n");
and the file..
        lrwxrwxrwx 1 root root 5 Apr 23 21:19 /tmp/this_is_a_symlink 
-> /bin/
the above obviously prints 'Success\n'. However, if I BREAK the symlink, with something like the following..
        lrwxrwxrwx 1 root root 4 Apr 23 21:21 /tmp/this_is_a_symlink 
-> foo
the script fails with.. Warning: stat failed for /tmp/this_is_a_symlink (errno=2 - No such file or directory) in ./test.php on line 3. The file /tmp/this_is_a_symlink is still a symlink, so it seems to me that the is_link() function should still return true, whether or not the
symlink's
target exists. Is there perhaps a function I have yet to discover that provides that behavior, without verifying the link's target?
I grew impatient, and devised a simple (2 line) workaround in filestat.c. Basically it just required NOT doing a stat() if is_link() was calling php_stat(). This probably isn't 'the' fix, but it works great for me, and I know you guys are pretty busy. Attached is my diff against php-4.0.4pl1's ext/standard/filestat.c. Thanks for the great language! Keep it up! J. Jones


« previous php.dev (#52342) next »