@@ -1,7 +1,7 @@ /* - * Copyright (c) 2008-2022 Jonathan Schleifer + * Copyright (c) 2008-2024 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -16,13 +16,13 @@ #include "config.h" #import "OFINIFileSettings.h" #import "OFArray.h" #import "OFINIFile.h" +#import "OFIRI.h" #import "OFString.h" #import "OFSystemInfo.h" -#import "OFURI.h" @implementation OFINIFileSettings - (instancetype)initWithApplicationName: (OFString *)applicationName { self = [super initWithApplicationName: applicationName]; @@ -30,13 +30,13 @@ @try { void *pool = objc_autoreleasePoolPush(); OFString *fileName; fileName = [applicationName stringByAppendingString: @".ini"]; - _fileURI = [[[OFSystemInfo userConfigURI] - URIByAppendingPathComponent: fileName] copy]; - _INIFile = [[OFINIFile alloc] initWithURI: _fileURI]; + _fileIRI = [[[OFSystemInfo userConfigIRI] + IRIByAppendingPathComponent: fileName] copy]; + _INIFile = [[OFINIFile alloc] initWithIRI: _fileIRI]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -45,11 +45,11 @@ return self; } - (void)dealloc { - [_fileURI release]; + [_fileIRI release]; [_INIFile release]; [super dealloc]; } @@ -74,11 +74,12 @@ { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; - [[_INIFile categoryForName: category] setString: string forKey: key]; + [[_INIFile categoryForName: category] setStringValue: string + forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setLongLong: (long long)longLong forPath: (OFString *)path @@ -85,12 +86,12 @@ { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; - [[_INIFile categoryForName: category] setLongLong: longLong - forKey: key]; + [[_INIFile categoryForName: category] setLongLongValue: longLong + forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setBool: (bool)bool_ forPath: (OFString *)path @@ -97,11 +98,11 @@ { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; - [[_INIFile categoryForName: category] setBool: bool_ forKey: key]; + [[_INIFile categoryForName: category] setBoolValue: bool_ forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setFloat: (float)float_ forPath: (OFString *)path @@ -108,11 +109,12 @@ { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; - [[_INIFile categoryForName: category] setFloat: float_ forKey: key]; + [[_INIFile categoryForName: category] setFloatValue: float_ + forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setDouble: (double)double_ forPath: (OFString *)path @@ -119,11 +121,12 @@ { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; - [[_INIFile categoryForName: category] setDouble: double_ forKey: key]; + [[_INIFile categoryForName: category] setDoubleValue: double_ + forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array @@ -131,12 +134,12 @@ { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; - [[_INIFile categoryForName: category] setStringArray: array - forKey: key]; + [[_INIFile categoryForName: category] setArrayValue: array + forKey: key]; objc_autoreleasePoolPop(pool); } - (OFString *)stringForPath: (OFString *)path @@ -144,12 +147,13 @@ { void *pool = objc_autoreleasePoolPush(); OFString *category, *key, *ret; [self of_getCategory: &category andKey: &key forPath: path]; - ret = [[_INIFile categoryForName: category] stringForKey: key - defaultValue: defaultValue]; + ret = [[_INIFile categoryForName: category] + stringValueForKey: key + defaultValue: defaultValue]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @@ -161,12 +165,12 @@ OFString *category, *key; long long ret; [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] - longLongForKey: key - defaultValue: defaultValue]; + longLongValueForKey: key + defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } @@ -176,12 +180,13 @@ void *pool = objc_autoreleasePoolPush(); OFString *category, *key; bool ret; [self of_getCategory: &category andKey: &key forPath: path]; - ret = [[_INIFile categoryForName: category] boolForKey: key - defaultValue: defaultValue]; + ret = [[_INIFile categoryForName: category] + boolValueForKey: key + defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } @@ -191,12 +196,13 @@ void *pool = objc_autoreleasePoolPush(); OFString *category, *key; float ret; [self of_getCategory: &category andKey: &key forPath: path]; - ret = [[_INIFile categoryForName: category] floatForKey: key - defaultValue: defaultValue]; + ret = [[_INIFile categoryForName: category] + floatValueForKey: key + defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } @@ -206,12 +212,13 @@ void *pool = objc_autoreleasePoolPush(); OFString *category, *key; double ret; [self of_getCategory: &category andKey: &key forPath: path]; - ret = [[_INIFile categoryForName: category] doubleForKey: key - defaultValue: defaultValue]; + ret = [[_INIFile categoryForName: category] + doubleValueForKey: key + defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } @@ -221,11 +228,11 @@ void *pool = objc_autoreleasePoolPush(); OFString *category, *key; OFArray *ret; [self of_getCategory: &category andKey: &key forPath: path]; - ret = [[_INIFile categoryForName: category] stringArrayForKey: key]; + ret = [[_INIFile categoryForName: category] arrayValueForKey: key]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @@ -241,8 +248,8 @@ objc_autoreleasePoolPop(pool); } - (void)save { - [_INIFile writeToURI: _fileURI]; + [_INIFile writeToIRI: _fileIRI]; } @end