mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Add method for getting all contents with specified name.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13743 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3ae2273e0d
commit
efc01e96e6
2 changed files with 44 additions and 0 deletions
|
@ -97,6 +97,7 @@
|
|||
- (NSString*) contentName;
|
||||
- (NSString*) contentSubType;
|
||||
- (NSString*) contentType;
|
||||
- (NSArray*) contentsByName: (NSString*)key;
|
||||
- (NSData*) convertToData;
|
||||
- (NSString*) convertToText;
|
||||
- (void) deleteHeader: (GSMimeHeader*)aHeader;
|
||||
|
|
|
@ -2884,6 +2884,49 @@ static NSCharacterSet *tokenSet = nil;
|
|||
return [hdr objectForKey: @"Type"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the content of this document to locate all parts whose content-type
|
||||
* name or content-disposition name matches the specified key.
|
||||
* Do <em>NOT</em> recurse into other documents.<br />
|
||||
* Return nil if no match is found, an array of matching GSMimeDocument
|
||||
* instances otherwise.
|
||||
*/
|
||||
- (NSArray*) contentsByName: (NSString*)key
|
||||
{
|
||||
NSMutableArray *a = nil;
|
||||
|
||||
if ([content isKindOfClass: [NSArray class]] == YES)
|
||||
{
|
||||
NSEnumerator *e = [content objectEnumerator];
|
||||
GSMimeDocument *d;
|
||||
|
||||
while ((d = [e nextObject]) != nil)
|
||||
{
|
||||
GSMimeHeader *hdr;
|
||||
BOOL match = YES;
|
||||
|
||||
hdr = [d headerNamed: @"content-type"];
|
||||
if ([[hdr parameterForKey: @"name"] isEqualToString: key] == NO)
|
||||
{
|
||||
hdr = [d headerNamed: @"content-disposition"];
|
||||
if ([[hdr parameterForKey: @"name"] isEqualToString: key] == NO)
|
||||
{
|
||||
match = NO;
|
||||
}
|
||||
}
|
||||
if (match == YES)
|
||||
{
|
||||
if (a == nil)
|
||||
{
|
||||
a = [NSMutableArray arrayWithCapacity: 4];
|
||||
}
|
||||
[a addObject: d];
|
||||
}
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the content as an NSData object (unless it is multipart)
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue