.lnk extension for windows files / shortcuts

From: Date: Sun, 18 Jul 2004 09:10:05 +0000
Subject: .lnk extension for windows files / shortcuts
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-190888@lists.php.net to get a copy of this message
Trejkaz, I'll make you a deal. I'll test out some code for you on my windows box and you test out my code on your linux box. I'm also building unit tests into the package so it should be easy to test everything. In any case, I started testing this out a little more on my box and noticed a few problems on the windows side. Namely, if a filename ends with the .lnk extension (WinXP) then the file is supposed to be a shortcut / link to another file. In this case the realpath can return true, even though opening the file (through the file manager) will actually open up the file it points to. AFAIK this is because links in PHP are simply not supported for windows - you'll have to do that checking manually. function is_absolute($path) { if (PHP_OS == 'WINNT' || PHP_OS == 'WIN32') {
    $pattern = '/^[a-zA-z]:.*[^.lnk]$/';
    return preg_match($pattern, $path);
} else {
    return $path{0} == '/';
} }

« previous php.general (#190888) next »