osx - Can PHP resolve a Mac alias? -
i running mamp , using php read names of files in given folder. create alias images in folder, , have php resolve these actual path. know how create symlinks work way, allow non-tech savvy web owners use mac os features familiar with.
i have created php script in same folder alias have named test:
<?php if (is_link ("test")) { echo "is link"; } else { echo "is not link"; } ?> this echoes "is not link". have tried using fread() command on link, php seems hang. neither logs error nor responds. have tried opening alias in hex editor see contains... hex editor opens seems huge file (if alias file), or opens target folder (if alias folder).
is there way php resolve path in alias? there applescript function can call?
chances you're not referring actual symbolic link. if you're dealing finder aliases, can use workaround found in comments is_link docs.
here contents of comment (to avoid link-only answer posterity):
if( getfinderalias( $somefile , $target ) ) { echo $target; } else { echo "file not alias"; } function getfinderalias( $filename , &$target ) { $getaliastarget = <<< heredoc -- begin applescript -- set checkfilestr "{$filename}" set checkfile checkfilestr posix file try tell application "finder" if original item of file checkfile exists set targetfile (original item of file checkfile) alias set postargetfile posix path of targetfile text 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 ); } here's explanation symlinks vs. aliases. though, should avoid using apple's abstractions , create symlink:
ln -s /path/to/file /path/to/symlink
Comments
Post a Comment