Last active
April 4, 2017 11:02
-
-
Save liufsd/c1e278f8a92f51b2090a77d27942f3bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DirectoryUtils.h | |
// PhotoCloud | |
// | |
// Created by liupeng on 14/11/2016. | |
// Copyright © 2016 liupeng. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface DirectoryUtils : NSObject | |
+(NSString* )RealHomeDirectory; | |
+(NSURL* )picturesDirectory; | |
+(NSURL* )downloadsDirectory; | |
+(NSURL* )moviesDirectory; | |
+(NSURL* )musicDirectory; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DirectoryUtils.m | |
// PhotoCloud | |
// | |
// Created by liupeng on 14/11/2016. | |
// Copyright © 2016 liupeng. All rights reserved. | |
// | |
#import "DirectoryUtils.h" | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <pwd.h> | |
@implementation DirectoryUtils | |
+(NSString* ) RealHomeDirectory | |
{ | |
struct passwd *pw = getpwuid(getuid()); | |
return [NSString stringWithUTF8String:pw->pw_dir]; | |
} | |
+(NSURL* )picturesDirectory { | |
return [[NSURL fileURLWithPath:[self RealHomeDirectory]] URLByAppendingPathComponent:@"Pictures"]; | |
} | |
+(NSURL* )downloadsDirectory { | |
return [[NSURL fileURLWithPath:[self RealHomeDirectory]] URLByAppendingPathComponent:@"Downloads"]; | |
} | |
+(NSURL* )moviesDirectory { | |
return [[NSURL fileURLWithPath:[self RealHomeDirectory]] URLByAppendingPathComponent:@"Movies"]; | |
} | |
+(NSURL* )musicDirectory { | |
return [[NSURL fileURLWithPath:[self RealHomeDirectory]] URLByAppendingPathComponent:@"Music"]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment