mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Start implementing some secure coding methods.
This commit is contained in:
parent
a9767cdff7
commit
082f87fbc3
2 changed files with 32 additions and 0 deletions
|
@ -87,6 +87,16 @@ extern "C" {
|
|||
*/
|
||||
+ (NSData*) archivedDataWithRootObject: (id)anObject;
|
||||
|
||||
|
||||
/**
|
||||
* Encodes anObject and returns the resulting data object. Allows
|
||||
* secure coding if specified. Returns an error if an object
|
||||
* violates secure coding rules.
|
||||
*/
|
||||
+ (NSData *) archivedDataWithRootObject: (id)anObject
|
||||
requiringSecureCoding: (BOOL)requiresSecureCoding
|
||||
error: (NSError **)error;
|
||||
|
||||
/**
|
||||
* Encodes anObject and writes the resulting data ti aPath.
|
||||
*/
|
||||
|
|
|
@ -460,6 +460,28 @@ static NSDictionary *makeReference(unsigned ref)
|
|||
return AUTORELEASE(d);
|
||||
}
|
||||
|
||||
+ (NSData *) archivedDataWithRootObject: (id)anObject
|
||||
requiringSecureCoding: (BOOL)requiresSecureCoding
|
||||
error: (NSError **)error
|
||||
{
|
||||
NSData *data = nil;
|
||||
if (requiresSecureCoding == YES)
|
||||
{
|
||||
*error = [NSError errorWithDomain: @"NSKeyedArchiver"
|
||||
code: 0
|
||||
userInfo: [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"Could not create secure keyed archive",
|
||||
NSLocalizedDescriptionKey, nil]];
|
||||
}
|
||||
else
|
||||
{
|
||||
error = NULL;
|
||||
data = [self archivedDataWithRootObject: anObject];
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
+ (BOOL) archiveRootObject: (id)anObject toFile: (NSString*)aPath
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
|
|
Loading…
Reference in a new issue