mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Optionally store defaults in windows registry.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21854 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
66e7354c1a
commit
6ebfe03cf3
5 changed files with 57 additions and 31 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2005-10-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSUserDefaults.m: More tweaks to use windows registry.
|
||||
* Source/win32/NSUserDefaultsWin32.m: Rewrite
|
||||
* Source/NSPathUtilities.m: Tweaks for windows.
|
||||
Updates to (optionally) use windows registry to store defaults
|
||||
when GNUSTEP_USER_DEFAULTS_DIR is set to ':REGISTRY:'
|
||||
Based on patch #4299 by Jeremy Bettis, but with rewrites to make use
|
||||
of the code configurable in the GNUstep configuration file, to fix
|
||||
some bugs, and to conform to coding standards, Probably still has
|
||||
bugs to fix, but seems usable now.
|
||||
|
||||
2005-10-20 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Source/NSBundle.m (+pathsForResourcesOfType:inDirectory:,
|
||||
|
|
|
@ -493,7 +493,10 @@ notice and this notice are preserved.
|
|||
relative to the user's home directory.</desc>
|
||||
<term>GNUSTEP_USER_DEFAULTS_DIR</term>
|
||||
<desc>Name of directory for user defaults files.
|
||||
Relative to the user's home directory.</desc>
|
||||
Relative to the user's home directory.<br />
|
||||
On mswindows this may be set to be ':REGISTRY:' to have defaults
|
||||
stored in the windows registry rather than in the standard file
|
||||
format.</desc>
|
||||
</deflist>
|
||||
<p>
|
||||
The user's home directory is taken to be the standard
|
||||
|
|
|
@ -48,12 +48,6 @@
|
|||
information required by the library to establish all locations required.
|
||||
</p>
|
||||
<p>
|
||||
On windows, the paths may also (as a fallback) be initialised by
|
||||
reading information from the windows registry.
|
||||
HKEY_LOCAL_MACHINE\Software\GNU\GNUstep contains the machine wide
|
||||
definititions for system paths.
|
||||
</p>
|
||||
<p>
|
||||
See <REF "filesystem.pdf">GNUstep File System Heirarchy</REF> document
|
||||
for more information and detailed descriptions.</p>
|
||||
</unit>
|
||||
|
@ -125,6 +119,12 @@ static NSString *gnustep_flattened =
|
|||
nil;
|
||||
#endif
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#define ATTRMASK 0700
|
||||
#else
|
||||
#define ATTRMASK 0777
|
||||
#endif
|
||||
|
||||
#define MGR() [NSFileManager defaultManager]
|
||||
|
||||
/*
|
||||
|
@ -501,11 +501,6 @@ static void InitialisePathUtilities(void)
|
|||
Win32NSStringFromRegistry(regkey, @"GNUSTEP_LOCAL_ROOT"));
|
||||
RegCloseKey(regkey);
|
||||
}
|
||||
#if 0
|
||||
// Not implemented yet
|
||||
platformApps = Win32FindDirectory(CLSID_APPS);
|
||||
platformLibs = Win32FindDirectory(CLSID_LIBS);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -602,15 +597,18 @@ ParseConfigurationFile(NSString *fileName, NSMutableDictionary *dict)
|
|||
}
|
||||
|
||||
attributes = [MGR() fileAttributesAtPath: fileName traverseLink: YES];
|
||||
if (([attributes filePosixPermissions] & 022) != 0)
|
||||
if (([attributes filePosixPermissions] & (0022 & ATTRMASK)) != 0)
|
||||
{
|
||||
#if defined(__WIN32__)
|
||||
fprintf(stderr, "The file '%S' is writable by someone other than"
|
||||
" its owner.\nIgnoring it.\n",
|
||||
(const unichar*)[fileName fileSystemRepresentation]);
|
||||
" its owner (permissions 0%lo).\nIgnoring it.\n",
|
||||
(const unichar*)[fileName fileSystemRepresentation],
|
||||
[attributes filePosixPermissions]);
|
||||
#else
|
||||
fprintf(stderr, "The file '%s' is writable by someone other than"
|
||||
" its owner.\nIgnoring it.\n", [fileName fileSystemRepresentation]);
|
||||
" its owner (permissions 0%lo).\nIgnoring it.\n",
|
||||
[fileName fileSystemRepresentation],
|
||||
[attributes filePosixPermissions]);
|
||||
#endif
|
||||
return NO;
|
||||
}
|
||||
|
@ -893,15 +891,18 @@ ParseConfigurationFile(NSString *fileName, NSMutableDictionary *dict)
|
|||
}
|
||||
|
||||
attributes = [MGR() fileAttributesAtPath: fileName traverseLink: YES];
|
||||
if (([attributes filePosixPermissions] & 022) != 0)
|
||||
if (([attributes filePosixPermissions] & (0022 & ATTRMASK)) != 0)
|
||||
{
|
||||
#if defined(__WIN32__)
|
||||
fprintf(stderr, "The file '%S' is writable by someone other than"
|
||||
" its owner.\nIgnoring it.\n",
|
||||
(const unichar*)[fileName fileSystemRepresentation]);
|
||||
" its owner (permissions 0%lo).\nIgnoring it.\n",
|
||||
(const unichar*)[fileName fileSystemRepresentation],
|
||||
[attributes filePosixPermissions]);
|
||||
#else
|
||||
fprintf(stderr, "The file '%s' is writable by someone other than"
|
||||
" its owner.\nIgnoring it.\n", [fileName fileSystemRepresentation]);
|
||||
" its owner (permissions 0%lo).\nIgnoring it.\n",
|
||||
[fileName fileSystemRepresentation],
|
||||
[attributes filePosixPermissions]);
|
||||
#endif
|
||||
return NO;
|
||||
}
|
||||
|
|
|
@ -461,7 +461,6 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
|
|||
// Create new sharedDefaults (NOTE: Not added to the autorelease pool!)
|
||||
#if defined(__MINGW32__)
|
||||
{
|
||||
#if 0
|
||||
NSString *path = GSDefaultsRootForUser(NSUserName());
|
||||
NSRange r = [path rangeOfString: @":REGISTRY:"];
|
||||
|
||||
|
@ -470,7 +469,6 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
|
|||
sharedDefaults = [[NSUserDefaultsWin32 alloc] init];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
sharedDefaults = [[self alloc] init];
|
||||
}
|
||||
|
@ -794,6 +792,15 @@ pathForUser(NSString *user)
|
|||
{
|
||||
path = pathForUser(NSUserName());
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
{
|
||||
NSRange r = [path rangeOfString: @":REGISTRY:"];
|
||||
if (r.length > 0)
|
||||
goto skipPathChecks;
|
||||
}
|
||||
#endif
|
||||
|
||||
path = [path stringByStandardizingPath];
|
||||
_defaultsDatabase = [path copy];
|
||||
path = [path stringByDeletingLastPathComponent];
|
||||
|
@ -824,6 +831,11 @@ pathForUser(NSString *user)
|
|||
_fileLock = [[NSDistributedLock alloc] initWithPath:
|
||||
[_defaultsDatabase stringByAppendingPathExtension: @"lck"]];
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
skipPathChecks:
|
||||
#endif
|
||||
|
||||
_lock = [GSLazyRecursiveLock new];
|
||||
|
||||
// Create an empty search list
|
||||
|
|
|
@ -33,7 +33,7 @@ struct NSUserDefaultsWin32_DomainInfo
|
|||
};
|
||||
|
||||
@implementation NSUserDefaultsWin32
|
||||
#ifdef NOTYET
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
DESTROY(registryPrefix);
|
||||
|
@ -52,7 +52,7 @@ struct NSUserDefaultsWin32_DomainInfo
|
|||
rc = RegCloseKey(dinfo->userKey);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
{
|
||||
NSString dPath;
|
||||
NSString *dPath;
|
||||
|
||||
dPath = [registryPrefix stringByAppendingString: domain];
|
||||
NSLog(@"Failed to close registry HKEY_CURRENT_USER\\%@ (%x)",
|
||||
|
@ -64,7 +64,7 @@ struct NSUserDefaultsWin32_DomainInfo
|
|||
rc = RegCloseKey(dinfo->systemKey);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
{
|
||||
NSString dPath;
|
||||
NSString *dPath;
|
||||
|
||||
dPath = [registryPrefix stringByAppendingString: domain];
|
||||
NSLog(@"Failed to close registry HKEY_LOCAL_MACHINE\\%@ (%x)",
|
||||
|
@ -100,8 +100,7 @@ struct NSUserDefaultsWin32_DomainInfo
|
|||
path = [path stringByAppendingString: @"\\"];
|
||||
}
|
||||
registryPrefix = RETAIN(path);
|
||||
noLegacyFile = YES;
|
||||
self = [super initWithContentsOfFile: @"C: /No/Such/File/Exists"];
|
||||
self = [super initWithContentsOfFile: @":REGISTRY:"];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -151,7 +150,7 @@ struct NSUserDefaultsWin32_DomainInfo
|
|||
}
|
||||
dPath = [registryPrefix stringByAppendingString: persistantDomain];
|
||||
|
||||
if (dinfo->userKey != 0)
|
||||
if (dinfo->userKey == 0)
|
||||
{
|
||||
rc = RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||
[dPath cString],
|
||||
|
@ -170,7 +169,7 @@ struct NSUserDefaultsWin32_DomainInfo
|
|||
return nil;
|
||||
}
|
||||
}
|
||||
if (dinfo->systemKey != 0)
|
||||
if (dinfo->systemKey == 0)
|
||||
{
|
||||
rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
[dPath cString],
|
||||
|
@ -348,7 +347,6 @@ struct NSUserDefaultsWin32_DomainInfo
|
|||
LONG rc;
|
||||
NSTimeInterval ti;
|
||||
NSString *dPath;
|
||||
NSString *dName;
|
||||
|
||||
dPath = [registryPrefix stringByAppendingString: domain];
|
||||
|
||||
|
@ -540,5 +538,5 @@ struct NSUserDefaultsWin32_DomainInfo
|
|||
}
|
||||
return YES;
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue