-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAFIRemoveCommand.m
52 lines (38 loc) · 1.48 KB
/
AFIRemoveCommand.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// AFIRemoveCommand.m
// Add Folder Icons
//
// Created by Andrew Hodgkinson on 7/03/16.
// Copyright © 2016 Hipposoft. All rights reserved.
//
#import "CoreServices/CoreServices.h" /* ...just for MacErrors.h, really */
#import "AFIRemoveCommand.h"
#import "GlobalConstants.h"
#import "IconStyleManager.h"
#import "ConcurrentPathProcessor.h"
@implementation AFIRemoveCommand
- ( id ) performDefaultImplementation
{
NSWorkspace * workspace = [ NSWorkspace sharedWorkspace ];
NSDictionary * args = [ self evaluatedArguments ];
NSArray * listOfFiles = @[];
/* Since the scripting definition file says that the one parameter is not
* optional, any AppleScript execution environment out to reject attempts
* to call us without one arguments exactly. But just in case...
*/
if ( args.count != 1 )
{
NSString * errorMessage = NSLocalizedString( @"A 'from <folder list>' parameter is required for the verb 'remove'.", @"Error message shown by the AppleScript 'remove' command handler if an incorrect number of parameters is supplied" );
[ self setScriptErrorNumber: errOSAScriptError ];
[ self setScriptErrorString: errorMessage ];
return nil;
}
listOfFiles = [ args valueForKey: @"fromFolders" ];
/* AppleScript sends 'file' types as NSURLs */
for ( NSURL * fileURL in listOfFiles )
{
[ workspace setIcon: nil forFile: [ fileURL path ] options: 0 ];
}
return nil;
}
@end