From 27c397fd78fe58ddc4bf66d2d37a0854f7edda16 Mon Sep 17 00:00:00 2001 From: CaS Date: Mon, 8 Jul 2002 11:19:23 +0000 Subject: [PATCH] Added file management stuff. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14069 72102866-910b-0410-8b05-ffd578937521 --- Testing/GNUmakefile | 2 ++ Testing/nsfilemanager.m | 57 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 Testing/nsfilemanager.m diff --git a/Testing/GNUmakefile b/Testing/GNUmakefile index 9674a4be6..fd55f08b9 100644 --- a/Testing/GNUmakefile +++ b/Testing/GNUmakefile @@ -58,6 +58,7 @@ TEST_TOOL_NAME = \ nsdate \ nsdictionary \ nsfilehandle \ + nsfilemanager \ nshashtable \ nshost \ nsinvocation \ @@ -99,6 +100,7 @@ nsdata_OBJC_FILES = nsdata.m nsdate_OBJC_FILES = nsdate.m nsdictionary_OBJC_FILES = nsdictionary.m nsfilehandle_OBJC_FILES = nsfilehandle.m +nsfilemanager_OBJC_FILES = nsfilemanager.m nshashtable_OBJC_FILES = nshashtable.m nshost_OBJC_FILES = nshost.m nsinvocation_OBJC_FILES = nsinvocation.m diff --git a/Testing/nsfilemanager.m b/Testing/nsfilemanager.m new file mode 100644 index 000000000..1368889f5 --- /dev/null +++ b/Testing/nsfilemanager.m @@ -0,0 +1,57 @@ +#include + +@interface Handler : NSObject +- (BOOL) fileManager: (NSFileManager*)manager +shouldProceedAfterError: (NSString*)error; +- (BOOL) fileManager: (NSFileManager*)manager +willProcessPath: (NSString*)path; +@end + +@implementation Handler +- (BOOL) fileManager: (NSFileManager*)manager +shouldProceedAfterError: (NSString*)error +{ + NSLog(@"Error - %@", error); + return NO; +} +- (BOOL) fileManager: (NSFileManager*)manager +willProcessPath: (NSString*)path +{ + NSLog(@"Processing %@", path); + return NO; +} +@end + +int +main () +{ + CREATE_AUTORELEASE_POOL(arp); + NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; + NSFileManager *mgr = [NSFileManager defaultManager]; + NSString *src; + NSString *dst; + Handler *handler = AUTORELEASE([Handler new]); + + src = [defs stringForKey: @"CopySrc"]; + dst = [defs objectForKey: @"CopyDst"]; + if (src != nil && dst != nil) + { + if ([mgr copyPath: src toPath: dst handler: handler] == NO) + { + NSLog(@"Copy %@ to %@ failed", src, dst); + } + } + + src = [defs stringForKey: @"Remove"]; + if (src != nil) + { + if ([mgr removeFileAtPath: src handler: handler] == NO) + { + NSLog(@"Remove %@ failed", src); + } + + } + + RELEASE(arp); + exit (0); +}