|
|
|
stsCreateShortcut(origFilePath,aliasPath[,shortCutName])
put stsCreateShortcut(tPath,tAliasPath)
put stsCreateShortcut(tPath,specialFolderPath(35),"MyAlias")
Creates an alias on Mac and Windows, getting around a bug in Rev where you can't create aliases to folders or disks (which includes OS X apps). Note: Creating aliases to network volumes on Mac OS X does not work. Note also that this code now no longer supports any non-OS X Mac System.
- origFilePath is the path to the file being aliased.
- aliasPath can either be a folder path, a file path, or a specialFolderPath (SFP) name.
- shortCutName is used to name the shortcut if aliasPath points to a folder or SFP (if aliasPath is supplied as a file path, the shortcut name is the file name in the supplied path).
on stsCreateShortcut pOrigFilePath,pAliasLoc,pShortcutName
-- Gets around a bug in Rev where you can't use 'create alias' on OS X bundles
--
-- pAliasLoc can either be a folder path, a file path, or a specialFolderPath name.
-- If supplied as a folder (or SFP), pShortCutName is used to name the shortcut
-- If supplied as a file, the shortcut name is the file name in the supplied path
-- First, check pOrigFilePath to confirm its existence
if (the platform is "MacOS") and char -4 to -1 of pOrigFilePath = ".app" then
-- need to check for a folder by that name
put (there is a folder pOrigFilePath) into tFound
put "folder" into tType
else
put (there is a folder pOrigFilePath) into tFound
if not(tFound) then
put (there is a file pOrigFilePath) into tFound
put "file" into tType
else
put "folder" into tType
end if
end if
if not(tFound) then
return "Error: Original file path at '" & pOrigFilePath & "' could not be found."
end if
if "/" is not in pAliasLoc then
-- assume it is a specialFolderPath name
put specialFolderPath(pAliasLoc) into pAliasLoc
if pAliasLoc="" then
-- something wrong with the SFP name
return "Error: Alias path at '" & pAliasLoc & "' could not be found."
end if
end if
if pShortCutName <> "" then
put pAliasLoc & "/" & pShortcutName into pAliasLoc
end if
set the itemDel to "/"
put item 1 to -2 of pAliasLoc into tFolder
put item -1 of pAliasLoc into pShortCutName
if there is not a folder tFolder then
return "Error: Folder for alias at '" & tFolder & "' could not be found."
end if
set the itemDel to ","
switch (the platform)
case "MacOS" -- assumes OS X
if tType = "folder" then
put "ln -s" && quote & pOrigFilePath & quote && quote & pAliasLoc & quote into tCmd
get shell(tCmd)
else
create alias pAliasLoc to file pOrigFilePath
end if
break
case "Win32"
-- Works for files, folders, and disks
if char -4 to -1 of pAliasLoc <> ".lnk" then put ".lnk" after pAliasLoc
create alias pAliasLoc to file pOrigFilePath
break
end switch
if "error" is not in the result then return ""
end stsCreateShortcut
| Date | Description |
| 5/10/07 |
Changed to use 'ln' for aliasing; removed OS 9 support.
|
| 9/30/06 |
Initial posting
|