• 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: Strange iDisk name (e.g., name-1)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange iDisk name (e.g., name-1)


  • Subject: Re: Strange iDisk name (e.g., name-1)
  • From: Jeffrey Mattox <email@hidden>
  • Date: Thu, 18 Dec 2003 02:22:01 -0600

Graff:

Your idea shows great promise.

1. There's a typo in the script. The innermost test should be (added "disk"):

if (the URL of disk theVolume) is equal to the iDiskUrl then

2. The code works, but not as you expected. The URL returned might not match the URL used when mounting the iDisk. If I force the Finder to mount my "name" iDisk at "name-1" (by manually creating a directory "name"), then the URL returned for my iDisk is:

file://localhost/Volumes/name-1/

However, if I assume that the iDisk is the only disk satisfying the first two conditions (is not network and is not local), then the URL contains the mount point of the iDisk, which is what I need to know. Great! To be even more sure, I can check for an exact match or a name with a dash.

So, for the record, here's a modified version of your script that works:

set idiskName to "name" -- your actual iDisk name goes here
set theMountPoint to ""
try
set theVolume to "http://idisk.mac.com/"; & idiskName -- returns "name:" or "name-1:"
set {delims, text item delimiters} to {text item delimiters, ""}
set theMountPoint to (characters 1 thru -2 of ((mount volume theVolume) as string) as string) -- remove trailing ":"
set text item delimiters to delims -- restore
on error theError number errorNumber
if (errorNumber is -55) then -- already mounted (it might be a "name-1")
set theNotLocatCount to 0
set theDiskList to list disks
set {delims, text item delimiters} to {text item delimiters, "/"}
tell application "Finder"
repeat with theVolume in theDiskList
if (theVolume as text) is not "Network" then
if (local volume of disk theVolume) is false then
set theURL to (the URL of disk theVolume)
-- expecting "file://localhost/Volumes/name/"
-- but could be "file://localhost/Volumes/name-1/"
set theTemp to text item -2 of theURL
if (theTemp is idiskName or theTemp starts with (idiskName & "-")) then
set theMountPoint to theTemp
set theNotLocatCount to theNotLocatCount + 1
end if
end if
end if
end repeat
end tell
set text item delimiters to delims -- restore
if (theNotLocatCount > 1) then -- warning
display dialog "WARNING: multiple non-network, non-local iDisks mounted"
end if
end if
end try
if (theMountPoint is "") then
display dialog "Unable to mount or find the iDisk"
else
display dialog "The iDisk '" & idiskName & "' is mounted at /Volumes/" & theMountPoint
end if


Thank you for your help.

Jeff


At 1:15 PM -0500 12/17/03, Graff wrote:
If the iDisk is already mounted perhaps you could get the URL of every mounted volume and compare it to the URL you are trying to mount? Then the disk that matches is the disk you would want to use.

I think the following code will work, but I don't have an iDisk to test it on. It seems to work fine with local volumes:
-------------
global theiDisk
global iDiskUrl
set iDiskUrl to "afp://"

set gotDisk to findDisk()

if gotDisk is false then
mount volume iDiskUrl
set gotDisk to findDisk()
end if

if gotDisk is false then
display dialog "Unable to mount or find the iDisk"
else
-- do something with the iDisk here
-- the variable "theiDisk" contains an alias to it
end if

on findDisk()
set iDiskFound to false
set volumeList to list disks
tell application "Finder"
repeat with theVolume in volumeList
if (theVolume as text) is not "Network" then
if (local volume of disk theVolume) is false then
if (the URL of theVolume) is equal to the iDiskUrl then
set theiDisk to theVolume
set iDiskFound to true
end if
end if
end if
end repeat
end tell
return iDiskFound
end findDisk
-------------

- Ken

On Dec 17, 2003, at 4:32 AM, Jeffrey Mattox wrote:

Ken:

I can't ask the user to select a name because most users wouldn't have a clue which name to choose. If there's more than one choice (e.g., "name" and "name-1"), the most obvious choice, "name", is the worst one because the OS didn't use it for some reason.

Your second idea sounds like it might work, but if mount volume actually mounts the iDisk, it returns the correct name, e.g., "name-1". The problem is if the iDisk is *already* mounted. In tat case, "mount volume" fails without returning a name and there won't be any change in the /Volumes directory.

Jeff


At 7:57 PM -0500 12/16/03, Graff wrote:
Well, I would handle it as a user choice. I'd ask the user where they wanted to save the file through a dialog:
set theFolder to choose folder

That way it could be handled intelligently by a person rather than just casting around with a script.

If you needed to do it without user interaction then I'd say you would have to first get a listing of the /Volumes directory, then mount, then get a second listing. Any new mount points in there should be the volumes you just mounted. Save references to those mount points and refer to them whenever you need to save to them.

- Ken

On Dec 16, 2003, at 5:34 PM, Jeffrey Mattox wrote:

I agree. The problem now is how does an AS program determine which directory in /Volumes should be used given a disk name?

At 12:04 PM -0500 12/16/03, Graff wrote:
Right, in the Volumes directory every name has to be unique. The way the OS handles this is to name any subsequent mounts with a suffix of "-1", "-2", etc. so they won't overwrite each other. The name of the volume as it appears to the Finder will probably be seen without the extra suffix because that is read from the volume information rather than from the name of the mount point. So you can have a couple of mounted disks with the same name in the Finder, but they will all have a unique name in /Volumes

This can result in one application getting the name of the volume with the suffix while another gets it without the suffix, depending on how they get the names.

- Ken

On Dec 16, 2003, at 11:35 AM, VRic wrote:

15/12/03 Jeffrey Mattox :

Sometimes an iDisk mounts as "name-1" instead of "name". What's up
with that?

I didn't pay much attention to it, but this happened to me recently when
mounting 2 similar disk images.

There seems to be discrepancies in the way OS X names the resulting
volumes and which name applications see (maybe new in Panther, and maybe
related to the new 2 flavors of mount).

2 disks with the same name should appear as such like in OS 9, but
probably the "Volumes" folder can't have 2 items with the same name and
applications don't seem to agree on where to get the volume name.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Strange iDisk name (e.g., name-1)
      • From: Graff <email@hidden>
References: 
 >Re: Strange iDisk name (e.g., name-1) (From: Graff <email@hidden>)
 >Re: Strange iDisk name (e.g., name-1) (From: Jeffrey Mattox <email@hidden>)
 >Re: Strange iDisk name (e.g., name-1) (From: Graff <email@hidden>)
 >Re: Strange iDisk name (e.g., name-1) (From: Jeffrey Mattox <email@hidden>)
 >Re: Strange iDisk name (e.g., name-1) (From: Graff <email@hidden>)

  • Prev by Date: (name-1), Is this a bug?
  • Next by Date: Re: How to prevent Classic from starting?
  • Previous by thread: Re: Strange iDisk name (e.g., name-1)
  • Next by thread: Re: Strange iDisk name (e.g., name-1)
  • Index(es):
    • Date
    • Thread