Removal off attachments included

This commit is contained in:
michael starke
2013-07-05 20:50:38 +02:00
parent 9c3a62bef6
commit 628fbbfeda
12 changed files with 543 additions and 293 deletions

View File

@@ -80,6 +80,31 @@
}
}
- (void)saveAttachmentFromEntry:(KdbEntry *)anEntry toLocation:(NSURL *)location {
if([anEntry isKindOfClass:[Kdb3Entry class]]) {
Kdb3Entry *entry = (Kdb3Entry *)anEntry;
NSError *error = nil;
if(! [entry.binary writeToURL:location options:NSDataWritingWithoutOverwriting error:&error] ) {
[NSApp presentError:error];
}
}
return; //
}
- (void)removeAttachment:(BinaryRef *)reference fromEntry:(KdbEntry *)anEntry {
if(self.version != MPDatabaseVersion4) {
return; // Wrong Database version;
}
Binary *binary = [self findBinary:reference];
Kdb4Entry *entry = (Kdb4Entry *)anEntry;
NSUInteger index = [entry.binaries indexOfObject:reference];
if(index == NSNotFound) {
return; // No Reference for this entry found
}
[entry removeObjectFromBinariesAtIndex:index];
[self.treeV4.binaries removeObject:binary];
}
- (Binary *)findBinary:(BinaryRef *)reference {
if(self.version != MPDatabaseVersion4) {
return nil;
@@ -110,17 +135,6 @@
}
}
- (void)saveAttachmentFromEntry:(KdbEntry *)anEntry toLocation:(NSURL *)location {
if([anEntry isKindOfClass:[Kdb3Entry class]]) {
Kdb3Entry *entry = (Kdb3Entry *)anEntry;
NSError *error = nil;
if(! [entry.binary writeToURL:location options:NSDataWritingWithoutOverwriting error:&error] ) {
[NSApp presentError:error];
}
}
return; //
}
- (NSUInteger)nextBinaryId {
if(self.version != MPDatabaseVersion4) {
return NSNotFound;