#import <Foundation/Foundation.h>
#import <Foundation/NSString.h>
#import <Foundation/NSFileManager.h>
#import <Foundation/NSAutoreleasePool.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *dirName = @"testdir";
NSString *path;
NSFileManager *fm;
fm = [NSFileManager defaultManager];
path = [fm currentDirectoryPath];
NSLog(@"Current directory path is %@",path);
//create the folder
if ([fm createDirectoryAtPath:dirName attributes:nil] == NO) {
NSLog(@"couldn't create directory!");
}
//Rename the folder
if([fm movePath:dirName toPath:@"newdir" handler:nil] == NO)
{
NSLog(@"Directory copy failed");
}
[pool drain];
return 0;
}
#import <Foundation/Foundation.h>
#import <Foundation/NSString.h>
#import <Foundation/NSFileManager.h>
#import <Foundation/NSAutoreleasePool.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *path;
NSFileManager *fm;
NSDirectoryEnumerator *dirEnum;
NSArray * dirArray;
fm = [NSFileManager defaultManager];
path = [fm currentDirectoryPath];
dirEnum = [fm enumeratorAtPath:path];
NSLog(@"Contents of %@:",path);
while ((path = [dirEnum nextObject]) != nil)
NSLog(@"%@",path);
dirArray = [fm directoryContentsAtPath:[fm currentDirectoryPath]];
NSLog(@"Contents using directoryContentsAtPath:");
for (path in dirArray)
{
NSLog(@"%@",path);
}
[pool drain];
return 0;
}