--- ../core/base/Source/NSUserDefaults.m.cvs 2004-01-17 15:07:07.000000000 +0800 +++ ../core/base/Source/NSUserDefaults.m 2004-01-17 17:02:48.000000000 +0800 @@ -613,25 +613,22 @@ return [self initWithUser: NSUserName()]; } +/* Returns the path to the user's ".GNUstepDefaults file" */ static NSString *pathForUser(NSString *user) { NSString *database = @".GNUstepDefaults"; NSFileManager *mgr = [NSFileManager defaultManager]; - NSString *home; NSString *path; - NSString *old; unsigned desired; NSDictionary *attr; BOOL isDir; - home = GSDefaultsRootForUser(user); - if (home == nil) + path = GSDefaultsRootForUser(user); + if (path == nil) { - /* Probably on MINGW. Where to put it? */ - NSLog(@"Could not get user root. Using NSOpenStepRootDirectory()"); - home = NSOpenStepRootDirectory(); + return [NSSearchPathForDirectoriesInDomains(NSUserDirectory, + NSUserDomainMask, YES) lastObject]; } - path = [home stringByAppendingPathComponent: @"Defaults"]; #if !(defined(S_IRUSR) && defined(S_IWUSR) && defined(S_IXUSR) \ && defined(S_IRGRP) && defined(S_IXGRP) \ @@ -645,80 +642,28 @@ [NSNumberClass numberWithUnsignedLong: desired], NSFilePosixPermissions, nil]; - if ([mgr fileExistsAtPath: home isDirectory: &isDir] == NO) - { - if ([mgr createDirectoryAtPath: home attributes: attr] == NO) - { - NSLog(@"Defaults home '%@' does not exist - failed to create it.", - home); - return nil; - } - else - { - NSLog(@"Defaults home '%@' did not exist - created it", home); - isDir = YES; - } - } - if (isDir == NO) - { - NSLog(@"ERROR - defaults home '%@' is not a directory!", home); - return nil; - } - if ([mgr fileExistsAtPath: path isDirectory: &isDir] == NO) { if ([mgr createDirectoryAtPath: path attributes: attr] == NO) - { - NSLog(@"Defaults path '%@' does not exist - failed to create it.", - path); - return nil; - } + { + NSLog(@"Defaults home '%@' does not exist - failed to create it.", + path); + return nil; + } else - { - NSLog(@"Defaults path '%@' did not exist - created it", path); - isDir = YES; - } + { + NSLog(@"Defaults home '%@' did not exist - created it", path); + isDir = YES; + } } if (isDir == NO) { - NSLog(@"ERROR - Defaults path '%@' is not a directory!", path); + NSLog(@"ERROR - defaults home '%@' is not a directory!", path); return nil; } +// NSLog(@"Determined Defaults home to be '%@'\n",path); path = [path stringByAppendingPathComponent: database]; - old = [home stringByAppendingPathComponent: database]; - if ([mgr fileExistsAtPath: path] == NO) - { - if ([mgr fileExistsAtPath: old] == YES) - { - if ([mgr movePath: old toPath: path handler: nil] == YES) - { - NSLog(@"Moved defaults database from old location (%@) to %@", - old, path); - } - } - } - if ([mgr fileExistsAtPath: old] == YES) - { - NSLog(@"Warning - ignoring old defaults database in %@", old); - } - - /* - * Try to create standard directory hierarchy if necessary - */ - home = [NSSearchPathForDirectoriesInDomains(NSUserDirectory, - NSUserDomainMask, YES) lastObject]; - if (home != nil) - { - NSString *p; - - p = [home stringByAppendingPathComponent: @"Library"]; - if ([mgr fileExistsAtPath: p isDirectory: &isDir] == NO) - { - [mgr createDirectoryAtPath: p attributes: attr]; - } - } - return path; }