Updates to use NSSearchPathForDirectoriesInDomains()

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@8848 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Jonathan Gapen 2001-01-28 12:26:36 +00:00
parent fbd8d04432
commit c1c64fa436
5 changed files with 37 additions and 58 deletions

View file

@ -334,7 +334,6 @@ static NSString *disabledName = @".GNUstepDisabled";
*/
+ (GSServicesManager*) newWithApplication: (NSApplication*)app
{
NSDictionary *env;
NSString *str;
NSString *path;
@ -347,11 +346,8 @@ static NSString *disabledName = @".GNUstepDisabled";
manager = [GSServicesManager alloc];
env = [[NSProcessInfo processInfo] environment];
str = [env objectForKey: @"GNUSTEP_USER_ROOT"];
if (str == nil)
str = [NSString stringWithFormat: @"%@/GNUstep",
NSHomeDirectory()];
str = [NSSearchPathForDirectoriesInDomains(NSUserDirectory,
NSUserDomainMask, YES) objectAtIndex: 0];
str = [str stringByAppendingPathComponent: @"Services"];
path = [str stringByAppendingPathComponent: servicesName];
manager->servicesPath = [path retain];

View file

@ -82,10 +82,11 @@ static NSLock *_gnustep_color_list_lock = nil;
// Load color lists found in standard paths into the array
// FIXME: Check exactly where in the directory tree we should scan.
e = [GSStandardPathPrefixes() objectEnumerator];
e = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSAllDomainsMask, YES) objectEnumerator];
while ((dir = (NSString *)[e nextObject]))
{
dir = [dir stringByAppendingPathComponent: @"Library/Colors"];
dir = [dir stringByAppendingPathComponent: @"Colors"];
de = [fm enumeratorAtPath: dir];
while ((file = [de nextObject]))
{
@ -322,8 +323,8 @@ static NSLock *_gnustep_color_list_lock = nil;
if (path == nil || ([fm fileExistsAtPath: path isDirectory: &isDir] == NO))
{
// FIXME the standard path for saving color lists?
path = [NSHomeDirectory () stringByAppendingPathComponent:
@"GNUstep/Library/Colors"];
path = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSUserDomainMask, YES) stringByAppendingPathComponent: @"Colors"];
isDir = YES;
}
@ -352,14 +353,9 @@ static NSLock *_gnustep_color_list_lock = nil;
else
{
tmpPath = [path stringByDeletingLastPathComponent];
if ([[tmpPath lastPathComponent] isEqualToString: @"Library"] == NO)
if ([NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSAllDomainsMask, YES) containsObject: tmpPath])
path_is_standard = NO;
else
{
tmpPath = [tmpPath stringByDeletingLastPathComponent];
if ([GSStandardPathPrefixes() containsObject: tmpPath] == NO)
path_is_standard = NO;
}
}
// If path is standard and it does not exist, try to create it.

View file

@ -46,12 +46,12 @@
#include <Foundation/NSDictionary.h>
#include <Foundation/NSException.h>
#include <Foundation/NSFileManager.h>
#include <Foundation/NSPathUtilities.h>
#include <Foundation/NSScanner.h>
#include <Foundation/NSString.h>
#include <Foundation/NSUtilities.h>
#include <Foundation/NSValue.h>
#include <Foundation/NSMapTable.h>
#include <Foundation/NSProcessInfo.h>
#include <AppKit/AppKitExceptions.h>
#include <AppKit/NSGraphics.h>
@ -348,11 +348,12 @@ andOptionTranslation:(NSString *)optionTranslation
+ (NSArray *)printerTypes
{
NSEnumerator *pathEnum;
NSBundle *lbdle;
NSArray *lpaths;
NSString *lpath;
NSArray *ppdpaths;
NSMutableArray *printers;
NSString *path;
NSDictionary *env;
NSAutoreleasePool *subpool; // There's a lot of temp strings used...
int i, max;
@ -362,36 +363,24 @@ andOptionTranslation:(NSString *)optionTranslation
printers = [[NSMutableArray array] retain];
subpool = [[NSAutoreleasePool alloc] init];
env = [[NSProcessInfo processInfo] environment];
lbdle = [NSBundle bundleWithPath: [env objectForKey: @"GNUSTEP_USER_ROOT"]];
lpaths = [lbdle pathsForResourcesOfType:@"ppd"
inDirectory:NSPrinter_PATH];
max = [lpaths count];
for(i=0 ; i<max ; i++)
pathEnum = [NSSearchPathForDirectoriesInDomains(GSLibrariesDirectory,
NSAllDomainsMask, YES) objectEnumerator];
while ((lpath = [pathEnum nextObject]))
{
path = [[lpaths objectAtIndex:i] lastPathComponent];
[printers addObject:[path substringToIndex:[path length]-4]];
}
lbdle = [NSBundle bundleWithPath: lpath];
ppdpaths = [lbdle pathsForResourcesOfType:@"ppd"
inDirectory:NSPrinter_PATH];
lbdle = [NSBundle bundleWithPath: [env objectForKey: @"GNUSTEP_LOCAL_ROOT"]];
lpaths = [lbdle pathsForResourcesOfType:@"ppd"
inDirectory:NSPrinter_PATH];
max = [lpaths count];
for(i=0 ; i<max ; i++)
{
path = [[lpaths objectAtIndex:i] lastPathComponent];
[printers addObject:[path substringToIndex:[path length]-4]];
}
lpaths = [[NSBundle gnustepBundle] pathsForResourcesOfType:@"ppd"
inDirectory:NSPrinter_PATH];
max = [lpaths count];
for(i=0 ; i<max ; i++)
{
path = [[lpaths objectAtIndex:i] lastPathComponent];
[printers addObject:[path substringToIndex:[path length]-4]];
// FIXME - should get name from contents of PPD, not filename
max = [ppdpaths count];
for (i = 0; i < max; i++)
{
path = [[ppdpaths objectAtIndex:i] lastPathComponent];
[printers addObject:[path substringToIndex:[path length]-4]];
}
}
[subpool release];
printerTypesAvailable = printers;
return printers;
}

View file

@ -41,7 +41,6 @@
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSTask.h>
#include <Foundation/NSException.h>
#include <Foundation/NSProcessInfo.h>
#include <Foundation/NSFileManager.h>
#include <Foundation/NSNotificationQueue.h>
#include <Foundation/NSDistributedNotificationCenter.h>
@ -172,7 +171,6 @@ static NSString *_rootPath = @"/";
{
static BOOL beenHere;
NSFileManager *mgr = [NSFileManager defaultManager];
NSDictionary *env;
NSString *home;
NSData *data;
NSDictionary *dict;
@ -191,16 +189,8 @@ static NSString *_rootPath = @"/";
workspaceCenter = [_GSWorkspaceCenter new];
iconMap = [NSMutableDictionary new];
/*
* The home directory for per-user information is given by
* the GNUSTEP_USER_ROOT environment variable, or is assumed
* to be the 'GNUstep' subdirectory of the users home directory.
*/
env = [[NSProcessInfo processInfo] environment];
if (!env || !(home = [env objectForKey: @"GNUSTEP_USER_ROOT"]))
{
home = [NSHomeDirectory() stringByAppendingPathComponent: @"GNUstep"];
}
home = [NSSearchPathForDirectoriesInDomains(NSUserDirectory,
NSUserDomainMask, YES) objectAtIndex: 0];
/*
* Load file extension preferences.