目录操作,mac os 16-5
来源:互联网 发布:caffe可视化 编辑:程序博客网 时间:2024/06/05 05:07
#import <Foundation/Foundation.h>int main(int argc, const char * argv[]){ @autoreleasepool { NSString *fName = @"path.m"; NSFileManager *fm; NSString *path, *tempdir, *extension, *homedir, *fullpath; NSArray *components; fm = [NSFileManager defaultManager]; //temp work dir tempdir = NSTemporaryDirectory(); NSLog(@"\nTemporary Directory is %@", tempdir); //current dir get base dir path = [fm currentDirectoryPath]; NSLog(@"\nBase dir is %@", [path lastPathComponent]); //create file fName in current dir ,all path fullpath = [path stringByAppendingPathComponent: fName]; NSLog(@"\nfullpath to %@ is %@", fName, fullpath); //get file extension name extension = [fullpath pathExtension]; NSLog(@"\nextension for %@ is %@", fullpath, extension); //get user main dir homedir = NSHomeDirectory(); NSLog(@"\nYour home directory is %@", homedir); components = [homedir pathComponents]; for( path in components) NSLog(@"%@", path); } return 0;}