• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Symlinks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Symlinks


  • Subject: Re: Symlinks
  • From: Tommy Bollman <email@hidden>
  • Date: Sat, 14 Aug 2010 02:45:20 +0200

Hello. 

It is corrected: I didn't add on the volume when given a path that started with "~"

on hfsPathOfAnythingAsText(anyFileOrFolderPath)
-- returns the full hfs pathname of anything if the files exists
local tids, theFile, lastItem, tidsToUse, singleQuoteCheck -- Thanks to Yvan Koenig :)
set singleQuoteCheck to false
set tidsToUse to ":"
try
(get class of anyFileOrFolderPath)
on error number -1728 -- it was a filereference
set fileOrFolderPath to fileOrFolderPath as alias as text
return fileOrFolderPath
end try


set anyFileOrFolderPath to "" & anyFileOrFolderPath -- doesn't harm.
if anyFileOrFolderPath starts with "'" and anyFileOrFolderPath ends with "'" then
set anyFileOrFolderPath to text 2 thru -2 of anyFileOrFolderPath
set singleQuoteCheck to true
end if
if anyFileOrFolderPath does not start with "/" and anyFileOrFolderPath does not start with "~" then
return anyFileOrFolderPath -- we had a hfspath
else
set tidsToUse to "/"
end if


set {tids, AppleScript's text item delimiters} to {AppleScript's text item delimiters, tidsToUse}
set anyFileOrFolderPath to text items of anyFileOrFolderPath as text
if singleQuoteCheck is true then
set AppleScript's text item delimiters to "'\\''"
set anyFileOrFolderPath to text items of anyFileOrFolderPath -- as list
set AppleScript's text item delimiters to "'"
end if
-- if tidstouse was "/" then we must add the disk name, - but which ???
set anyFileOrFolderPath to "" & anyFileOrFolderPath
set AppleScript's text item delimiters to tidsToUse
if text item 1 of anyFileOrFolderPath is "~" then
set anyFileOrFolderPath to {item 1 of (list disks)} & text items 2 thru -2 of (POSIX path of (path to home folder) as text) & text items 2 thru -1 of anyFileOrFolderPath
else if text item 2 of anyFileOrFolderPath is "Volumes" then
set anyFileOrFolderPath to text items 3 thru -1 of anyFileOrFolderPath
else
set anyFileOrFolderPath to {item 1 of (list disks)} & text items 2 thru -1 of anyFileOrFolderPath
end if
set AppleScript's text item delimiters to ":"
set anyFileOrFolderPath to "" & anyFileOrFolderPath
set AppleScript's text item delimiters to tids
return anyFileOrFolderPath
end hfsPathOfAnythingAsText

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: symlinks
  • Next by Date: Re: Libraries and effiency
  • Previous by thread: Re: Symlinks
  • Next by thread: Re: Symlinks, I sent the wrong handler :-)
  • Index(es):
    • Date
    • Thread