diff --git a/ChangeLog b/ChangeLog index a3950b176..36869115b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2012-08-13 Wolfgang Sourdeau + * SoObjects/SOGo/NSString+Utilities.m + (-stringByReplacingPrefix:withPrefix:): new self-explicit method. + * OpenChange/SOGoMAPIDBFolder.m (-childKeysOfType:includeDeleted:matchingQualifier:andSortOrderings:): records now have a c_parent_path column in order to avoid fetch diff --git a/SoObjects/SOGo/NSString+Utilities.h b/SoObjects/SOGo/NSString+Utilities.h index 409c3fe86..df82535e2 100644 --- a/SoObjects/SOGo/NSString+Utilities.h +++ b/SoObjects/SOGo/NSString+Utilities.h @@ -74,7 +74,8 @@ /* substrings */ - (NSUInteger) countOccurrencesOfString: (NSString *) substring; - +- (NSString *) stringByReplacingPrefix: (NSString *) oldPrefix + withPrefix: (NSString *) newPrefix; /* Those methods provide symmetric enc-/decryption via a XOR operation */ - (NSString *) encryptWithKey: (NSString *) theKey; diff --git a/SoObjects/SOGo/NSString+Utilities.m b/SoObjects/SOGo/NSString+Utilities.m index ec04b9795..da5a69993 100644 --- a/SoObjects/SOGo/NSString+Utilities.m +++ b/SoObjects/SOGo/NSString+Utilities.m @@ -560,6 +560,24 @@ static int cssEscapingCount; return count; } +- (NSString *) stringByReplacingPrefix: (NSString *) oldPrefix + withPrefix: (NSString *) newPrefix +{ + NSUInteger oldPrefixLength; + NSString *newString; + + if (![self hasPrefix: oldPrefix]) + [NSException raise: NSInvalidArgumentException + format: @"string does not have the specified prefix"]; + + oldPrefixLength = [oldPrefix length]; + newString = [NSString stringWithFormat: @"%@%@", + newPrefix, + [self substringFromIndex: oldPrefixLength]]; + + return newString; +} + - (NSString *) encryptWithKey: (NSString *) theKey { NSMutableData *encryptedPassword;