mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +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
7a2eeb1de4
commit
81949e70cd
5 changed files with 57 additions and 31 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue