mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Added file management stuff.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14069 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
03d6b239b1
commit
d745ee8b68
2 changed files with 59 additions and 0 deletions
|
@ -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
|
||||
|
|
57
Testing/nsfilemanager.m
Normal file
57
Testing/nsfilemanager.m
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include <Foundation/Foundation.h>
|
||||
|
||||
@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);
|
||||
}
|
Loading…
Reference in a new issue