mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +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
5000b2d5c7
commit
27c397fd78
2 changed files with 59 additions and 0 deletions
|
@ -58,6 +58,7 @@ TEST_TOOL_NAME = \
|
||||||
nsdate \
|
nsdate \
|
||||||
nsdictionary \
|
nsdictionary \
|
||||||
nsfilehandle \
|
nsfilehandle \
|
||||||
|
nsfilemanager \
|
||||||
nshashtable \
|
nshashtable \
|
||||||
nshost \
|
nshost \
|
||||||
nsinvocation \
|
nsinvocation \
|
||||||
|
@ -99,6 +100,7 @@ nsdata_OBJC_FILES = nsdata.m
|
||||||
nsdate_OBJC_FILES = nsdate.m
|
nsdate_OBJC_FILES = nsdate.m
|
||||||
nsdictionary_OBJC_FILES = nsdictionary.m
|
nsdictionary_OBJC_FILES = nsdictionary.m
|
||||||
nsfilehandle_OBJC_FILES = nsfilehandle.m
|
nsfilehandle_OBJC_FILES = nsfilehandle.m
|
||||||
|
nsfilemanager_OBJC_FILES = nsfilemanager.m
|
||||||
nshashtable_OBJC_FILES = nshashtable.m
|
nshashtable_OBJC_FILES = nshashtable.m
|
||||||
nshost_OBJC_FILES = nshost.m
|
nshost_OBJC_FILES = nshost.m
|
||||||
nsinvocation_OBJC_FILES = nsinvocation.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…
Add table
Add a link
Reference in a new issue