Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

-ks_setBundleBit:forFileAtURL:

  • Loading branch information...
commit 241f907975e4f65079a839e504e2593e09cc7347 1 parent 28831d8
Mike Abdullah mikeabdullah authored
Showing with 36 additions and 0 deletions.
  1. +4 −0 KSWorkspaceUtilities.h
  2. +32 −0 KSWorkspaceUtilities.m
4 KSWorkspaceUtilities.h
View
@@ -33,4 +33,8 @@
- (NSImage *)ks_iconForType:(NSString *)aUTI;
+#pragma mark Bundle Bit
+- (void)ks_setBundleBit:(BOOL)flag forFileAtURL:(NSURL *)url;
+
+
@end
32 KSWorkspaceUtilities.m
View
@@ -211,4 +211,36 @@ - (NSImage *)ks_iconForType:(NSString *)aUTI;
return result;
}
+#pragma mark
+
+- (void)ks_setBundleBit:(BOOL)flag forFileAtURL:(NSURL *)url;
+{
+ FSRef fileRef;
+ OSErr error = FSPathMakeRef((UInt8 *)[[url path] fileSystemRepresentation], &fileRef, NULL);
+
+ // Get the file's current info
+ FSCatalogInfo fileInfo;
+ if (!error)
+ {
+ error = FSGetCatalogInfo(&fileRef, kFSCatInfoFinderInfo, &fileInfo, NULL, NULL, NULL);
+ }
+
+ if (!error)
+ {
+ // Adjust the bundle bit
+ FolderInfo *finderInfo = (FolderInfo *)fileInfo.finderInfo;
+ if (flag) {
+ finderInfo->finderFlags |= kHasBundle;
+ }
+ else {
+ finderInfo->finderFlags &= ~kHasBundle;
+ }
+
+ // Set the altered flags of the file
+ error = FSSetCatalogInfo(&fileRef, kFSCatInfoFinderInfo, &fileInfo);
+ }
+
+ if (error) NSLog(@"OSError %i in -[NSWorkspace setBundleBit:forFile:]", error);
+}
+
@end
Please sign in to comment.
Something went wrong with that request. Please try again.