Implemented getting and setting properties

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@8147 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-11-18 06:40:23 +00:00
parent 7c297f6781
commit 64cff1558f
2 changed files with 29 additions and 5 deletions

View file

@ -35,6 +35,7 @@
#include <Foundation/NSURLHandle.h>
#include <Foundation/NSURL.h>
#include <Foundation/NSRunLoop.h>
#include <Foundation/NSFileManager.h>
@class GSFileURLHandle;
@class GSHTTPURLHandle;
@ -405,7 +406,8 @@ static Class NSURLHandleClass = 0;
@interface GSFileURLHandle : NSURLHandle
{
NSString *_path;
NSString *_path;
NSMutableDictionary *_attributes;
}
@end
@ -534,23 +536,40 @@ static NSLock *fileLock = nil;
- (id) propertyForKey: (NSString*)propertyKey
{
return nil;
NSDictionary *dict;
dict = [[NSFileManager defaultManager] fileAttributesAtPath: _path
traverseLink: YES];
RELEASE(_attributes);
_attributes = [dict mutableCopy];
return [_attributes objectForKey: propertyKey];
}
- (id) propertyForKeyIfAvailable: (NSString*)propertyKey
{
return nil;
return [_attributes objectForKey: propertyKey];
}
- (BOOL) writeData: (NSData*)data
{
return [data writeToFile: _path atomically: YES];
if ([data writeToFile: _path atomically: YES] == YES)
{
ASSIGNCOPY(_data, data);
return YES;
}
return NO;
}
- (BOOL) writeProperty: (id)propertyValue
forKey: (NSString*)propertyKey
{
return NO;
if ([self propertyForKey: propertyKey] == nil)
{
return NO; /* Not a valid file property key. */
}
[_attributes setObject: propertyValue forKey: propertyKey];
return [[NSFileManager defaultManager] changeFileAttributes: _attributes
atPath: _path];
}
@end