Differences From Artifact [33a908e3eb]:
- File
src/OFINIFile.m
— part of check-in
[44f45c2e35]
at
2017-01-09 17:36:36
on branch trunk
— Update copyright
Forgot to add 2017, even though I already did quite some changes in
2017. (user: js, size: 4161) [annotate] [blame] [check-ins using]
To Artifact [3398a352d7]:
- File
src/OFINIFile.m
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 4171) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
25 26 27 28 29 30 31 | #import "OFINICategory.h" #import "OFINICategory+Private.h" #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" @interface OFINIFile () | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #import "OFINICategory.h" #import "OFINICategory+Private.h" #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" @interface OFINIFile () - (void)OF_parseFile: (OFString *)path encoding: (of_string_encoding_t)encoding; @end static bool isWhitespaceLine(OFString *line) { const char *cString = [line UTF8String]; |
︙ | ︙ | |||
51 52 53 54 55 56 57 | } } return true; } @implementation OFINIFile | | | | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | } } return true; } @implementation OFINIFile + (instancetype)fileWithPath: (OFString *)path { return [[[self alloc] initWithPath: path] autorelease]; } + (instancetype)fileWithPath: (OFString *)path encoding: (of_string_encoding_t)encoding { return [[[self alloc] initWithPath: path encoding: encoding] autorelease]; } - init { OF_INVALID_INIT_METHOD } - initWithPath: (OFString *)path { return [self initWithPath: path encoding: OF_STRING_ENCODING_UTF_8]; } - initWithPath: (OFString *)path encoding: (of_string_encoding_t)encoding { self = [super init]; @try { _categories = [[OFMutableArray alloc] init]; |
︙ | ︙ | |||
99 100 101 102 103 104 105 | - (void)dealloc { [_categories release]; [super dealloc]; } | | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | - (void)dealloc { [_categories release]; [super dealloc]; } - (OFINICategory *)categoryForName: (OFString *)name { void *pool = objc_autoreleasePoolPush(); OFINICategory *category; for (category in _categories) { if ([[category name] isEqual: name]) { OFINICategory *ret = [category retain]; |
︙ | ︙ | |||
125 126 127 128 129 130 131 | [category retain]; objc_autoreleasePoolPop(pool); return [category autorelease]; } | | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | [category retain]; objc_autoreleasePoolPop(pool); return [category autorelease]; } - (void)OF_parseFile: (OFString *)path encoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); OFFile *file; OFINICategory *category = nil; OFString *line; |
︙ | ︙ | |||
172 173 174 175 176 177 178 | [category OF_parseLine: line]; } } objc_autoreleasePoolPop(pool); } | | | | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | [category OF_parseLine: line]; } } objc_autoreleasePoolPop(pool); } - (void)writeToFile: (OFString *)path { [self writeToFile: path encoding: OF_STRING_ENCODING_UTF_8]; } - (void)writeToFile: (OFString *)path encoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); OFFile *file = [OFFile fileWithPath: path mode: @"w"]; bool first = true; |
︙ | ︙ |