From ba01b14ce26061f81741acace03685206bbfdc6e Mon Sep 17 00:00:00 2001 From: CaS Date: Mon, 5 Jan 2004 18:28:18 +0000 Subject: [PATCH] Add method for consistency git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18320 72102866-910b-0410-8b05-ffd578937521 --- Headers/Additions/GNUstepBase/GSMime.h | 1 + Source/Additions/GSMime.m | 29 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Headers/Additions/GNUstepBase/GSMime.h b/Headers/Additions/GNUstepBase/GSMime.h index 44fa7c2b5..a9837f743 100644 --- a/Headers/Additions/GNUstepBase/GSMime.h +++ b/Headers/Additions/GNUstepBase/GSMime.h @@ -120,6 +120,7 @@ - (NSArray*) contentsByName: (NSString*)key; - (NSData*) convertToData; - (NSString*) convertToText; +- (void) deleteContent: (GSMimeDocument*)aPart; - (void) deleteHeader: (GSMimeHeader*)aHeader; - (void) deleteHeaderNamed: (NSString*)name; - (GSMimeHeader*) headerNamed: (NSString*)name; diff --git a/Source/Additions/GSMime.m b/Source/Additions/GSMime.m index 3cd7b9c35..e18233661 100644 --- a/Source/Additions/GSMime.m +++ b/Source/Additions/GSMime.m @@ -3705,6 +3705,35 @@ static NSCharacterSet *tokenSet = nil; [super dealloc]; } +/** + * Deletes all ocurrances of parts identical to aPart from the receiver.
+ * Recursively deletes from enclosed documents as necessary. + */ +- (void) deleteContent: (GSMimeDocument*)aPart +{ + if (aPart != nil) + { + if ([content isKindOfClass: [NSMutableArray class]] == YES) + { + unsigned count = [content count]; + + while (count-- > 0) + { + GSMimeDocument *part = [content objectAtIndex: count]; + + if (part == aPart) + { + [content removeObjectAtIndex: count]; + } + else + { + [part deleteContent: part]; // Recursive. + } + } + } + } +} + /** * This method removes all occurrances of header objects identical to * the one supplied as an argument.