mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
MacOS-X compatibility fixups.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24203 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
58e0c0338f
commit
aed6c6902f
3 changed files with 153 additions and 84 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2006-12-14 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Foundation/NSPathUtilities.h:
|
||||
* Source/NSPathUtilities.m:
|
||||
Update constants to be MacOS-X compatible, including addition of a
|
||||
few more keys added in recent versions.
|
||||
Fix bug/misfeature of only returning paths which exist on the
|
||||
filesystem ... which broke MacOS-X applications which were correctly
|
||||
expecting to find a non-existent path and create it as a location
|
||||
to store their resources in.
|
||||
|
||||
2006-12-13 David Ayers <ayers@fsfe.org>
|
||||
|
||||
* Source/mframe.m (mframe_do_call),
|
||||
|
|
|
@ -122,42 +122,53 @@ GS_EXPORT NSString *NSHomeDirectoryForUser(NSString *loginName);
|
|||
NSDeveloperDirectory,
|
||||
NSUserDirectory,
|
||||
NSDocumentationDirectory,
|
||||
NSDocumentDirectory,
|
||||
NSCoreServiceDirectory,
|
||||
NSDesktopDirectory,
|
||||
NSCachesDirectory,
|
||||
NSApplicationSupportDirectory
|
||||
NSAllApplicationsDirectory,
|
||||
NSAllLibrariesDirectory,
|
||||
GSLibrariesDirectory,
|
||||
GSToolsDirectory,
|
||||
GSApplicationSupportDirectory
|
||||
GSFontsDirectory,
|
||||
GSFrameworksDirectory
|
||||
}
|
||||
</example>
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NSApplicationDirectory,
|
||||
NSDemoApplicationDirectory,
|
||||
NSDeveloperApplicationDirectory,
|
||||
NSAdminApplicationDirectory,
|
||||
NSLibraryDirectory,
|
||||
NSDeveloperDirectory,
|
||||
NSUserDirectory,
|
||||
NSDocumentationDirectory,
|
||||
|
||||
/* Apple Reserved Directory Identifiers */
|
||||
NSApplicationDirectory = 1, /** Applications */
|
||||
NSDemoApplicationDirectory, /** Demos */
|
||||
NSDeveloperApplicationDirectory, /** Developer/Applications */
|
||||
NSAdminApplicationDirectory, /** Administration */
|
||||
NSLibraryDirectory, /** Library */
|
||||
NSDeveloperDirectory, /** Developer */
|
||||
NSUserDirectory, /** user home directories */
|
||||
NSDocumentationDirectory, /** Documentation */
|
||||
#if OS_API_VERSION(100200, GS_API_LATEST)
|
||||
NSDocumentDirectory, /** Documents */
|
||||
#endif
|
||||
#if OS_API_VERSION(100300, GS_API_LATEST)
|
||||
NSCoreServicesDirectory, /** CoreServices */
|
||||
#endif
|
||||
#if OS_API_VERSION(100400, GS_API_LATEST)
|
||||
NSDesktopDirectory = 12, /** location of users desktop */
|
||||
NSCachesDirectory = 13, /** location of users cache files */
|
||||
NSApplicationSupportDirectory = 14, /** location of app support files */
|
||||
#endif
|
||||
|
||||
NSAllApplicationsDirectory,
|
||||
NSAllLibrariesDirectory,
|
||||
NSAllApplicationsDirectory = 100, /** all app directories */
|
||||
NSAllLibrariesDirectory = 101, /** all library resources */
|
||||
|
||||
/* GNUstep Directory Identifiers */
|
||||
|
||||
//GSApplicationSupportDirectory = 150,
|
||||
//GSFontsDirectory,
|
||||
//GSFrameworksDirectory,
|
||||
GSLibrariesDirectory,
|
||||
GSToolsDirectory,
|
||||
GSApplicationSupportDirectory,
|
||||
GSPreferencesDirectory,
|
||||
|
||||
GSFontsDirectory,
|
||||
GSFrameworksDirectory
|
||||
#define GSApplicationSupportDirectory NSApplicationSupportDirectory
|
||||
/* GNUstep Directory Identifiers
|
||||
* Start at 1000, we hope Apple will never overlap.
|
||||
*/
|
||||
GSLibrariesDirectory = 1000, /** libraries (binary code) */
|
||||
GSToolsDirectory, /** non-gui programs */
|
||||
GSFontsDirectory, /** font storage */
|
||||
GSFrameworksDirectory /** frameworks */
|
||||
} NSSearchPathDirectory;
|
||||
|
||||
/**
|
||||
|
@ -167,18 +178,67 @@ typedef enum
|
|||
*/
|
||||
typedef enum
|
||||
{
|
||||
NSUserDomainMask = 1,
|
||||
NSLocalDomainMask = 2,
|
||||
NSNetworkDomainMask = 4,
|
||||
NSSystemDomainMask = 8,
|
||||
NSAllDomainsMask = 0xffffffff,
|
||||
NSUserDomainMask = 1, /** The user's personal items */
|
||||
NSLocalDomainMask = 2, /** Local for all users on the machine */
|
||||
NSNetworkDomainMask = 4, /** Public for all users on network */
|
||||
NSSystemDomainMask = 8, /** Standard GNUstep items */
|
||||
NSAllDomainsMask = 0x0ffff, /** all domains */
|
||||
} NSSearchPathDomainMask;
|
||||
|
||||
/**
|
||||
* Returns an array of search paths to look at for resources.<br/ >
|
||||
* The paths are returned in domain order:
|
||||
* USER, LOCAL, NETWORK then SYSTEM.<br />
|
||||
* The presence of a path in this list does <em>not</em> mean that the
|
||||
* path actually exists in the filesystem.<br />
|
||||
* If you are wanting to locate an existing resource, you should normally
|
||||
* call this function with NSAllDomainsMask, but if you wish to find the
|
||||
* path in which you should create a new file, you would generally
|
||||
* specify a particular domain, and then create the path in the file
|
||||
* system if it does not already exist.
|
||||
*/
|
||||
GS_EXPORT NSArray *NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory directoryKey, NSSearchPathDomainMask domainMask, BOOL expandTilde);
|
||||
|
||||
/**
|
||||
* Returns the full username of the current user.
|
||||
* If unable to determine this, returns the standard user name.
|
||||
*/
|
||||
GS_EXPORT NSString *NSFullUserName(void);
|
||||
|
||||
/**
|
||||
* Returns the standard paths in which applications are stored and
|
||||
* should be searched for. Calls NSSearchPathForDirectoriesInDomains()<br/ >
|
||||
* Refer to the GNUstep File System Hierarchy documentation for more info.
|
||||
*/
|
||||
GS_EXPORT NSArray *NSStandardApplicationPaths(void);
|
||||
|
||||
/**
|
||||
* Returns the standard paths in which resources are stored and
|
||||
* should be searched for. Calls NSSearchPathForDirectoriesInDomains()<br/ >
|
||||
* Refer to the GNUstep File System Hierarchy documentation for more info.
|
||||
*/
|
||||
GS_EXPORT NSArray *NSStandardLibraryPaths(void);
|
||||
|
||||
/**
|
||||
* Returns the name of a directory in which temporary files can be stored.
|
||||
* Under GNUstep this is a location which is not readable by other users.
|
||||
* <br />
|
||||
* If a suitable directory can't be found or created, this function raises an
|
||||
* NSGenericException.
|
||||
*/
|
||||
GS_EXPORT NSString *NSTemporaryDirectory(void);
|
||||
|
||||
/**
|
||||
* Returns the location of the <em>root</em> directory of the file
|
||||
* hierarchy. This lets you build paths in a system independent manner
|
||||
* (for instance the root on unix is '/' but on windows it is 'C:\')
|
||||
* by appending path components to the root.<br />
|
||||
* Don't assume that /System, /Network etc exist in this path (generally
|
||||
* they don't)! Use other path utility functions such as
|
||||
* NSSearchPathForDirectoriesInDomains() to find standard locations
|
||||
* for libraries, applications etc.<br />
|
||||
* Refer to the GNUstep File System Hierarchy documentation for more info.
|
||||
*/
|
||||
GS_EXPORT NSString *NSOpenStepRootDirectory(void);
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
|
|
|
@ -1128,10 +1128,6 @@ NSHomeDirectoryForUser(NSString *loginName)
|
|||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full username of the current user.
|
||||
* If unable to determine this, returns the standard user name.
|
||||
*/
|
||||
NSString *
|
||||
NSFullUserName(void)
|
||||
{
|
||||
|
@ -1208,11 +1204,6 @@ GSDefaultsRootForUser(NSString *userName)
|
|||
return home;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the standard paths in which applications are stored and
|
||||
* should be searched for. Calls NSSearchPathForDirectoriesInDomains()<br/ >
|
||||
* Refer to the GNUstep File System Hierarchy documentation for more info.
|
||||
*/
|
||||
NSArray *
|
||||
NSStandardApplicationPaths(void)
|
||||
{
|
||||
|
@ -1220,11 +1211,6 @@ NSStandardApplicationPaths(void)
|
|||
NSAllDomainsMask, YES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the standard paths in which resources are stored and
|
||||
* should be searched for. Calls NSSearchPathForDirectoriesInDomains()<br/ >
|
||||
* Refer to the GNUstep File System Hierarchy documentation for more info.
|
||||
*/
|
||||
NSArray *
|
||||
NSStandardLibraryPaths(void)
|
||||
{
|
||||
|
@ -1232,13 +1218,6 @@ NSStandardLibraryPaths(void)
|
|||
NSAllDomainsMask, YES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of a directory in which temporary files can be stored.
|
||||
* Under GNUstep this is a location which is not readable by other users.
|
||||
* <br />
|
||||
* If a suitable directory can't be found or created, this function raises an
|
||||
* NSGenericException.
|
||||
*/
|
||||
NSString *
|
||||
NSTemporaryDirectory(void)
|
||||
{
|
||||
|
@ -1387,17 +1366,6 @@ NSTemporaryDirectory(void)
|
|||
return tempDirName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location of the <em>root</em> directory of the file
|
||||
* hierarchy. This lets you build paths in a system independent manner
|
||||
* (for instance the root on unix is '/' but on windows it is 'C:\')
|
||||
* by appending path components to the root.<br />
|
||||
* Don't assume that /System, /Network etc exist in this path (generally
|
||||
* they don't)! Use other path utility functions such as
|
||||
* NSSearchPathForDirectoriesInDomains() to find standard locations
|
||||
* for libraries, applications etc.<br />
|
||||
* Refer to the GNUstep File System Hierarchy documentation for more info.
|
||||
*/
|
||||
NSString *
|
||||
NSOpenStepRootDirectory(void)
|
||||
{
|
||||
|
@ -1413,10 +1381,6 @@ NSOpenStepRootDirectory(void)
|
|||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of search paths to look at for resources.<br/ >
|
||||
* The paths are returned in domain order: USER, LOCAL, NETWORK then SYSTEM.
|
||||
*/
|
||||
NSArray *
|
||||
NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory directoryKey,
|
||||
NSSearchPathDomainMask domainMask, BOOL expandTilde)
|
||||
|
@ -1426,8 +1390,9 @@ NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory directoryKey,
|
|||
static NSString *devDir = @"Developer";
|
||||
static NSString *demosDir = @"Demos";
|
||||
static NSString *libraryDir = @"Library";
|
||||
static NSString *supportDir = @"ApplicationSupport";
|
||||
static NSString *supportDir = @"Library/ApplicationSupport";
|
||||
static NSString *docDir = @"Documentation";
|
||||
static NSString *docsDir = @"Documentats";
|
||||
static NSString *fontsDir = @"Fonts";
|
||||
static NSString *frameworkDir = @"Frameworks";
|
||||
static NSString *libsDir = @"Libraries";
|
||||
|
@ -1522,6 +1487,27 @@ if (domainMask & mask) \
|
|||
}
|
||||
break;
|
||||
|
||||
case NSCoreServicesDirectory:
|
||||
{
|
||||
NSString *coreDir;
|
||||
|
||||
coreDir = [devDir stringByAppendingPathComponent:
|
||||
@"Library/CoreServices"];
|
||||
ADD_PATH(NSSystemDomainMask, gnustepSystemRoot, coreDir);
|
||||
}
|
||||
break;
|
||||
|
||||
case NSDesktopDirectory:
|
||||
{
|
||||
NSString *deskDir;
|
||||
|
||||
// FIXME ... what should desktop really be?
|
||||
deskDir = [devDir stringByAppendingPathComponent:
|
||||
@"Desktop"];
|
||||
ADD_PATH(NSUserDomainMask, gnustepUserRoot, deskDir);
|
||||
}
|
||||
break;
|
||||
|
||||
case NSDeveloperApplicationDirectory:
|
||||
{
|
||||
NSString *devAppsDir;
|
||||
|
@ -1603,8 +1589,32 @@ if (domainMask & mask) \
|
|||
}
|
||||
break;
|
||||
|
||||
/* Now the GNUstep additions */
|
||||
case GSApplicationSupportDirectory:
|
||||
case NSDocumentDirectory:
|
||||
{
|
||||
NSString *gsdocDir;
|
||||
|
||||
gsdocDir = [libraryDir stringByAppendingPathComponent: docsDir];
|
||||
ADD_PATH(NSUserDomainMask, gnustepUserRoot, gsdocDir);
|
||||
ADD_PATH(NSLocalDomainMask, gnustepLocalRoot, gsdocDir);
|
||||
ADD_PATH(NSNetworkDomainMask, gnustepNetworkRoot, gsdocDir);
|
||||
ADD_PATH(NSSystemDomainMask, gnustepSystemRoot, gsdocDir);
|
||||
}
|
||||
break;
|
||||
|
||||
case NSCachesDirectory:
|
||||
{
|
||||
NSString *cacheDir;
|
||||
|
||||
cacheDir = [libraryDir stringByAppendingPathComponent:
|
||||
@"Library/Caches"];
|
||||
ADD_PATH(NSUserDomainMask, gnustepUserRoot, cacheDir);
|
||||
ADD_PATH(NSLocalDomainMask, gnustepLocalRoot, cacheDir);
|
||||
ADD_PATH(NSNetworkDomainMask, gnustepNetworkRoot, cacheDir);
|
||||
ADD_PATH(NSSystemDomainMask, gnustepSystemRoot, cacheDir);
|
||||
}
|
||||
break;
|
||||
|
||||
case NSApplicationSupportDirectory:
|
||||
{
|
||||
NSString *appSupDir;
|
||||
|
||||
|
@ -1616,6 +1626,7 @@ if (domainMask & mask) \
|
|||
}
|
||||
break;
|
||||
|
||||
/* Now the GNUstep additions */
|
||||
case GSFrameworksDirectory:
|
||||
{
|
||||
NSString *frameDir;
|
||||
|
@ -1717,12 +1728,6 @@ if (domainMask & mask) \
|
|||
ADD_PLATFORM_PATH(NSSystemDomainMask, osSysAdmin);
|
||||
}
|
||||
break;
|
||||
|
||||
case GSPreferencesDirectory:
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#undef ADD_PATH
|
||||
|
@ -1733,17 +1738,10 @@ if (domainMask & mask) \
|
|||
{
|
||||
path = [paths objectAtIndex: i];
|
||||
|
||||
/* remove paths which don't exist on this system */
|
||||
if ([MGR() fileExistsAtPath: path] == NO)
|
||||
{
|
||||
[paths removeObjectAtIndex: i];
|
||||
i--;
|
||||
count--;
|
||||
}
|
||||
else if (expandTilde == YES)
|
||||
if (expandTilde == YES)
|
||||
{
|
||||
[paths replaceObjectAtIndex: i
|
||||
withObject: [path stringByExpandingTildeInPath]];
|
||||
withObject: [path stringByExpandingTildeInPath]];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue