Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 59 lines (45 sloc) 1.305 kb
a3b7edff »
2011-04-28 KSWorkspaceUtilities
1 //
2 // KSWorkspaceUtilities.m
3 // Sandvox
4 //
5 // Created by Mike on 28/04/2011.
5e343eda »
2012-01-02 update copyrights to 2012
6 // Copyright 2011-2012 Karelia Software. All rights reserved.
a3b7edff »
2011-04-28 KSWorkspaceUtilities
7 //
8
9 #import "KSWorkspaceUtilities.h"
10
ba68e079 »
2011-04-28 UTI handling methods
11 #import "KSURLUtilities.h"
12
a3b7edff »
2011-04-28 KSWorkspaceUtilities
13
14 @implementation NSWorkspace (KSWorkspaceUtilities)
15
28831d88 »
2011-04-28 -ks_iconForType:
16 #pragma mark Requesting Information
17
18 - (NSImage *)ks_iconForType:(NSString *)aUTI;
19 {
20 NSString *extension = [self preferredFilenameExtensionForType:aUTI];
21 NSImage *result = [self iconForFileType:extension];
22 //[result normalizeSize];
23 return result;
24 }
25
241f9079 »
2011-04-28 -ks_setBundleBit:forFileAtURL:
26 #pragma mark
27
28 - (void)ks_setBundleBit:(BOOL)flag forFileAtURL:(NSURL *)url;
29 {
30 FSRef fileRef;
31 OSErr error = FSPathMakeRef((UInt8 *)[[url path] fileSystemRepresentation], &fileRef, NULL);
32
33 // Get the file's current info
34 FSCatalogInfo fileInfo;
35 if (!error)
36 {
37 error = FSGetCatalogInfo(&fileRef, kFSCatInfoFinderInfo, &fileInfo, NULL, NULL, NULL);
38 }
39
40 if (!error)
41 {
42 // Adjust the bundle bit
43 FolderInfo *finderInfo = (FolderInfo *)fileInfo.finderInfo;
44 if (flag) {
45 finderInfo->finderFlags |= kHasBundle;
46 }
47 else {
48 finderInfo->finderFlags &= ~kHasBundle;
49 }
50
51 // Set the altered flags of the file
52 error = FSSetCatalogInfo(&fileRef, kFSCatInfoFinderInfo, &fileInfo);
53 }
54
55 if (error) NSLog(@"OSError %i in -[NSWorkspace setBundleBit:forFile:]", error);
56 }
57
a3b7edff »
2011-04-28 KSWorkspaceUtilities
58 @end
Something went wrong with that request. Please try again.