The example code contains a problem; FolderItem.Item resolves
aliases. So this method may not do what you thought it would. You
need to use TrueItem. Also, you need to check the value returned by
TrueItem to make sure that it's not nil, because it certainly can be.
To determine whether a folder is a bundle without the use of a
plugin, see the Launch Services chapter of my book on declares at
<http://www.declareSub.com/>. In it there is a function IsBundled
that calls Launch Services to answer the question.
Charles Yeomans
On Dec 17, 2006, at 5:16 PM, [EMAIL PROTECTED] wrote:
In playing with the following code from the Language Reference for
a simple cataloging app I'm working on, I've come across a problem.
It seems that RB doesn't necessarily see applications like a single
file, and instead sees it as the folder/package that it really is,
which can cause all sorts of issues. So, I've been trying to figure
out a way for RB to look at an application and see it as an actual
application. I've been mucking about with the code that follows
(IsItAnApp subroutine), but I'm having a tough time finding the
right combo of qualifiers that work. Does anyone have any
(preferably) simple code that qualifies apps vs.folders? I'm
considering going with Applescript or maybe a shell script of some
kind (don't have a lue how to do that yet), but I would prefer to
keep it "pure" RB for the sake of speed and easy maintenance.
[code]
Sub CopyFileorFolder (source as FolderItem, destination as
FolderItem)
Dim i as Integer
Dim newFolder as FolderItem
If...Then...Else source.directory then //it's a folder
newFolder=destination.child(source.name)
newFolder.createAsFolder
For i=1 to source.count //go through each item
If source.item(i).directory then
//it's a folder
If IsItAnApp(source.item(i)) = false then //My code
CopyFileOrFolder source.item(i), newFolder
End If
//recursively call this
//routine passing it the folder
else
source.item(i).CopyFileTo newFolder
//it's a file so copy it
end if
next
else //it's not a folder
source.CopyFileTo destination
end if
Sub IsItAnApp (theCurrentItem as FolderItem) as boolean
if theCurrentItem.Child("Contents").Exists then
if theCurrentItem.Child("Contents").Child("Info.plist").exists
then
return true
end if
elseif theCurrentItem.Child("Info.plist").Exists then
return true
elseif theCurrentItem.MacType = "APPL" then
return true
elseif Right(theCurrentItem.Name, 4) <> ".app" then
return true
end if
return false
[/code]
Thanks for any help!
--
Philip Regan\
[EMAIL PROTECTED]
RB 2K5r4, Mac OS 10.3.9, Applescript
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>