mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
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:
parent
7c297f6781
commit
64cff1558f
2 changed files with 29 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2000-11-18 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSURLHandle.m: Implemented setting and gettign of properties
|
||||||
|
for file handles using NSFileManager.
|
||||||
|
|
||||||
2000-11-17 Richard Frith-Macdonald <rfm@gnu.org>
|
2000-11-17 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Headers/Foundation/GSMime.h: Added GSMimeEncodingContext etc
|
* Headers/Foundation/GSMime.h: Added GSMimeEncodingContext etc
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <Foundation/NSURLHandle.h>
|
#include <Foundation/NSURLHandle.h>
|
||||||
#include <Foundation/NSURL.h>
|
#include <Foundation/NSURL.h>
|
||||||
#include <Foundation/NSRunLoop.h>
|
#include <Foundation/NSRunLoop.h>
|
||||||
|
#include <Foundation/NSFileManager.h>
|
||||||
|
|
||||||
@class GSFileURLHandle;
|
@class GSFileURLHandle;
|
||||||
@class GSHTTPURLHandle;
|
@class GSHTTPURLHandle;
|
||||||
|
@ -405,7 +406,8 @@ static Class NSURLHandleClass = 0;
|
||||||
|
|
||||||
@interface GSFileURLHandle : NSURLHandle
|
@interface GSFileURLHandle : NSURLHandle
|
||||||
{
|
{
|
||||||
NSString *_path;
|
NSString *_path;
|
||||||
|
NSMutableDictionary *_attributes;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -534,23 +536,40 @@ static NSLock *fileLock = nil;
|
||||||
|
|
||||||
- (id) propertyForKey: (NSString*)propertyKey
|
- (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
|
- (id) propertyForKeyIfAvailable: (NSString*)propertyKey
|
||||||
{
|
{
|
||||||
return nil;
|
return [_attributes objectForKey: propertyKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) writeData: (NSData*)data
|
- (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
|
- (BOOL) writeProperty: (id)propertyValue
|
||||||
forKey: (NSString*)propertyKey
|
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
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue