Differences From Artifact [f704cad7e3]:
- File
src/XMPPFileStorage.m
— part of check-in
[cd21ff1157]
at
2018-11-05 22:30:18
on branch trunk
— Kill #ifdef HAVE_CONFIG_H
There no longer is an Xcode project for which it is needed. (user: js, size: 5121) [annotate] [blame] [check-ins using]
To Artifact [51fa277e00]:
- File src/XMPPFileStorage.m — part of check-in [abf66b5c9b] at 2019-03-16 20:58:13 on branch trunk — Use dot syntax (user: js, size: 5118) [annotate] [blame] [check-ins using]
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2012, 2019, Jonathan Schleifer <js@webkeks.org> * * https://heap.zone/objxmpp/ * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice is present in all copies. * |
︙ | ︙ | |||
46 47 48 49 50 51 52 | self = [super init]; @try { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; _file = [file copy]; @try { | | | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | self = [super init]; @try { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; _file = [file copy]; @try { _data = [[OFData dataWithContentsOfFile: file] .messagePackValue copy]; } @catch (id e) { _data = [[OFMutableDictionary alloc] init]; } [pool release]; } @catch (id e) { [self release]; |
︙ | ︙ | |||
71 72 73 74 75 76 77 | [_data release]; [super dealloc]; } - (void)save { | | | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | [_data release]; [super dealloc]; } - (void)save { [_data.messagePackRepresentation writeToFile: _file]; } - (void)xmpp_setObject: (id)object forPath: (OFString *)path { OFArray *pathComponents = [path componentsSeparatedByString: @"."]; OFMutableDictionary *iter = _data; size_t i = 0, components = pathComponents.count; for (OFString *component in pathComponents) { if (i++ == components - 1) continue; OFMutableDictionary *iter2 = [iter objectForKey: component]; if (iter2 == nil) { iter2 = [OFMutableDictionary dictionary]; [iter setObject: iter2 forKey: component]; } iter = iter2; } if (object != nil) [iter setObject: object forKey: [pathComponents lastObject]]; else [iter removeObjectForKey: pathComponents.lastObject]; } - (id)xmpp_objectForPath: (OFString *)path { id object = _data; for (OFString *component in [path componentsSeparatedByString: @"."]) |
︙ | ︙ |