This function returns "false" for windows *.lnk files (tested under windows XP).
filetype also returns "file" an not "link" like expected.
I didn`t find a solution for this.
is_link
(PHP 4, PHP 5)
is_link — filename이 심볼릭 링크인지 아닌지 이야기하기
Description
bool is_link
( string $filename
)
filename이 존재하고 심볼릭링크된 파일이라면 TRUE
이 함수의 실행결과는 캐시가 됩니다. 좀 더 자세한 내용을 알고 싶으면 clearstatcache()를 보세요.
Note: 이 함수는 윈도우즈에서는 동작하지 않습니다.
is_link
radon8472 at hotmail dot com
31-Jul-2008 09:38
31-Jul-2008 09:38
mbirth at webwriters dot de
20-May-2008 08:24
20-May-2008 08:24
To find out whether a file is hardlinked to another filename, check the number of links of the stat() output. If it is >1 there is another filename for that file.
To find out whether two filenames are pointing to the same file, check the inode number of those 2 filenames. If it is equal, the 2 filenames are hardlinked together.
neverpanic->gmail[com]
30-Dec-2006 02:50
30-Dec-2006 02:50
For me (Debian Sarge VPS) is_link returns true even for directories if you don't add a trailing slash to the filename.
<?php
if ($dir{strlen($dir)-1} == '/') $dir = substr($dir, 0, -1);
is_link($dir);
?>
This works for me. It can't detect a symlink somewhere in a complete path, though (i.e. is_link(/www/somedir/file.php) will return false, just as is_link(/www/) would)
brendy at gmail dot com
05-May-2006 07:22
05-May-2006 07:22
On Mac OSX, to see if a file is a FInder alias:
<?PHP
if( getFinderAlias( $someFile , $target ) ) {
echo $target;
}
else {
echo "File is not an alias";
}
function getFinderAlias( $filename , &$target ) {
$getAliasTarget = <<< HEREDOC
-- BEGIN APPLESCRIPT --
set checkFileStr to "{$filename}"
set checkFile to checkFileStr as POSIX file
try
tell application "Finder"
if original item of file checkFile exists then
set targetFile to (original item of file checkFile) as alias
set posTargetFile to POSIX path of targetFile as text
get posTargetFile
end if
end tell
end try
-- END APPLESCRIPT --
HEREDOC;
$runText = "osascript << EOS\n{$getAliasTarget}\nEOS\n";
$target = trim( shell_exec( $runText ) );
return ( $target == "" ? false : true );
}
?>
jr at cnb dot uam dot es
30-May-2005 11:31
30-May-2005 11:31
Why don't you just try
is_dir("$pathname/.")
instead?
If $pathname is a directory, $pathname/. is itself and is a directory too.
If $pathname is a link to a directory, then $pathname/. is the actual directory pointed at and is a directory as well.
If $pathname is a link to a non-directory, then $pathname/. does not exist and returns FALSE, as it should.
A lot easier, more readable and intuitive.
andudi at gmx dot ch
02-Jun-2002 10:44
02-Jun-2002 10:44
On my SuSE 7.2 is_link does not work on directories, but to find out, if a dir is a link, I use now this:
$linkdir = $path.$linkdirname;
if (realpath($linkdir) != realpath($path)."/".$linkdirname):
//$linkdir is a symbolic linked dir!
...
and this works fine :-)
Andreas Dick
aris at riponce dot com
27-Mar-2001 02:27
27-Mar-2001 02:27
If you test a symbolic (soft) link with is_file() it will return true. Either use filetype() which always returns the correct type OR make sure that you FIRST test with is_link() before you do with is_file() to get the correct type.
