Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // NSFileManager+openFinderFolder.m
- //
- // Created by Jonathan Annett on 28/10/13.
- // Copyright (c) 2013 Sophtwhere. All rights reserved.
- //
- #import "NSFileManager+openFinderFolder.h"
- NSString *openInFinderFolderFormat = @"/usr/bin/open \"%@\"" ;
- NSString *revealInFinderFormat = @"/usr/bin/open -R \"%@\"";
- @implementation NSFileManager (openFinderFolder)
- -(void) openFinderFolderAtPath:(NSString*) path {
- #if TARGET_IPHONE_SIMULATOR
- BOOL isDirectory = NO;
- if ([self fileExistsAtPath:path isDirectory:&isDirectory]) {
- if (isDirectory) {
- NSString *openCommand = [NSString stringWithFormat:openInFinderFolderFormat, path];
- system([openCommand fileSystemRepresentation]);
- }
- }
- #endif
- }
- -(void) revealItemInFinder:(NSString*) path {
- #if TARGET_IPHONE_SIMULATOR
- BOOL isDirectory = NO;
- if ([self fileExistsAtPath:path isDirectory:&isDirectory]) {
- NSString *openCommandFormat = isDirectory ? openInFinderFolderFormat : revealInFinderFormat;
- NSString *openCommand = [NSString stringWithFormat:openCommandFormat, path];
- system([openCommand fileSystemRepresentation]);
- }
- #endif
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement