 |
 |
determining if a file is applescript
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
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
|
|
|
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
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
|
|
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'."
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
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
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
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
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|