Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > determining if a file is applescript

determining if a file is applescript
Thread Tools
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Aug 27, 2004, 06:14 PM
 
when iTunes enumerates through its scripts directory in order to create the menuItems for the script menu, how does it determine whether a file is indeed an applescript? What test can i perform on a file, given its path, to determine this? Its not the extension, an applescript may or may not end in .scpt. It could end in .app and not all files that end in .app are applescripts. If i put a regular .app in the script folder, iTunes is smart enough to know its not a script.

any ideas?
3R1C
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Aug 27, 2004, 07:47 PM
 
Type and creator codes.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status: Offline
Reply With Quote
Aug 27, 2004, 11:39 PM
 
a few notes:

It is definitely not type and creator codes, you can put a flat file in there and it will work.

It is not simply AppleScript files that can go in there. It does have to be executable, and osascript languages get a bunch of benefits (getting access to the program they were called in). I believe that regular .app packages are specifically excluded.

What is your real question here... you are trying to do something, what is it? Learn to ask better questions (or how to ask the questions better).
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Aug 28, 2004, 12:57 PM
 
I just tested, and it does appear to be type and creator codes. I tried the following:

1. Remove the creator code from an AppleScript app. iTunes didn't recognize it. (The 'aplt' creator code is the only thing that distinguishes it from a normal app.)
2. Remove just the type and creator codes from a script. iTunes recognized it.
3. Remove just the extension of a script. iTunes recognized it.
4. Remove both the type and creator codes and the extension. iTunes didn't recognize it.

This would seem to indicate that my hypothesis was correct.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
3R1C  (op)
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Aug 28, 2004, 02:33 PM
 
Thank you very much kind sir. This isnt the first time youve come thru with the goods. I guess my question must have been put well enough for some at least.
3R1C
     
3R1C  (op)
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Sep 11, 2004, 05:50 AM
 
Just to stitch up this thread for others in the future, heres the method I use in a category on NSFilemanager

Code:
// creators // 1685089396 == dplt droplet script // 1416591699 == ToyS regular script // 1634757748 == aplt compiled script //types //1869832563 == osas applescript - (BOOL) fileAtPathIsScript:(NSString *)thePath { id theFileAttributes = [self fileAttributesAtPath:thePath traverseLink:YES]; if ([[theFileAttributes objectForKey:NSFileHFSTypeCode] intValue] == 1869832563) { return YES; } int theCreator = [[theFileAttributes objectForKey:NSFileHFSCreatorCode] intValue]; if ((theCreator == 1416591699) || (theCreator == 1634757748) || (theCreator == 1685089396)) { return YES; } return NO; }
(Last edited by 3R1C; Sep 15, 2004 at 08:56 PM. )
3R1C
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:12 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2