From 2d0d7623b79c4b7e9d86386eaa90ddda0a8fad27 Mon Sep 17 00:00:00 2001 From: Nicola Pero Date: Tue, 6 Mar 2007 14:03:49 +0000 Subject: [PATCH] Implemented properly NSUserDirectory git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24780 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 10 +++++ Headers/Additions/GNUstepBase/config.h.in | 51 +++++++++++++---------- Source/NSPathUtilities.m | 27 ++++++++++-- configure | 47 +++++++++++++++++++++ configure.ac | 35 ++++++++++++++++ 5 files changed, 145 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index ff04d935e..66735158d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-03-06 Nicola Pero + + * configure.ac: Added GNUSTEP_SYSTEM_USERS_DIR, + GNUSTEP_NETWORK_USERS_DIR and GNUSTEP_LOCAL_USERS_DIR. + * configure: Regenerated. + * Headers/Additions/GNUstepBase/config.h.in: Regenerated. + * Source/NSPathUtilities.m: Read and process the new variables; + fixed NSUserDirectory to return the proper GNUSTEP_*_USERS_DIR + instead of the user's home directory. + 2007-03-06 Richard Frith-Macdonald * Source/NSUserDefaults.m: On mswindows, don't count a '.exe' diff --git a/Headers/Additions/GNUstepBase/config.h.in b/Headers/Additions/GNUstepBase/config.h.in index 260fc0cf0..299ada32a 100644 --- a/Headers/Additions/GNUstepBase/config.h.in +++ b/Headers/Additions/GNUstepBase/config.h.in @@ -18,9 +18,6 @@ /* Built in default value for GNUstep local apps */ #undef GNUSTEP_TARGET_LOCAL_ADMIN_APPS -/* Built in default value for GNUstep local web apps */ -#undef GNUSTEP_TARGET_LOCAL_WEB_APPS - /* Built in default value for GNUstep local tools */ #undef GNUSTEP_TARGET_LOCAL_ADMIN_TOOLS @@ -48,15 +45,18 @@ /* Built in default value for GNUstep local tools */ #undef GNUSTEP_TARGET_LOCAL_TOOLS +/* Built in default value for GNUstep Local Users directory */ +#undef GNUSTEP_TARGET_LOCAL_USERS_DIR + +/* Built in default value for GNUstep local web apps */ +#undef GNUSTEP_TARGET_LOCAL_WEB_APPS + /* Built in default value for GNUstep Makefiles */ #undef GNUSTEP_TARGET_MAKEFILES /* Built in default value for GNUstep network apps */ #undef GNUSTEP_TARGET_NETWORK_ADMIN_APPS -/* Built in default value for GNUstep network web apps */ -#undef GNUSTEP_TARGET_NETWORK_WEB_APPS - /* Built in default value for GNUstep system tools */ #undef GNUSTEP_TARGET_NETWORK_ADMIN_TOOLS @@ -84,12 +84,15 @@ /* Built in default value for GNUstep network tools */ #undef GNUSTEP_TARGET_NETWORK_TOOLS +/* Built in default value for GNUstep Network Users directory */ +#undef GNUSTEP_TARGET_NETWORK_USERS_DIR + +/* Built in default value for GNUstep network web apps */ +#undef GNUSTEP_TARGET_NETWORK_WEB_APPS + /* Built in default value for GNUstep system apps */ #undef GNUSTEP_TARGET_SYSTEM_ADMIN_APPS -/* Built in default value for GNUstep system web apps */ -#undef GNUSTEP_TARGET_SYSTEM_WEB_APPS - /* Built in default value for GNUstep system tools */ #undef GNUSTEP_TARGET_SYSTEM_ADMIN_TOOLS @@ -117,6 +120,12 @@ /* Built in default value for GNUstep system tools */ #undef GNUSTEP_TARGET_SYSTEM_TOOLS +/* Built in default value for GNUstep System Users directory */ +#undef GNUSTEP_TARGET_SYSTEM_USERS_DIR + +/* Built in default value for GNUstep web apps */ +#undef GNUSTEP_TARGET_SYSTEM_WEB_APPS + /* Built in default value for GNUstep user config file */ #undef GNUSTEP_TARGET_USER_CONFIG_FILE @@ -126,12 +135,9 @@ /* Built in default value for GNUstep user directory */ #undef GNUSTEP_TARGET_USER_DIR -/* Built in default value for GNUstep user_dir apps */ +/* Built in default value for GNUstep user_dir admin apps */ #undef GNUSTEP_TARGET_USER_DIR_ADMIN_APPS -/* Built in default value for GNUstep user_dir web apps */ -#undef GNUSTEP_TARGET_USER_DIR_WEB_APPS - /* Built in default value for GNUstep user_dir tools */ #undef GNUSTEP_TARGET_USER_DIR_ADMIN_TOOLS @@ -159,6 +165,9 @@ /* Built in default value for GNUstep user_dir tools */ #undef GNUSTEP_TARGET_USER_DIR_TOOLS +/* Built in default value for GNUstep user_dir web apps */ +#undef GNUSTEP_TARGET_USER_DIR_WEB_APPS + /* Define if this constant is defined */ #undef HANDLE_LLONG_MAX @@ -549,25 +558,25 @@ /* Define to 1 if the `setpgrp' function takes no argument. */ #undef SETPGRP_VOID -/* The size of `double', as computed by sizeof. */ +/* The size of a `double', as computed by sizeof. */ #undef SIZEOF_DOUBLE -/* The size of `float', as computed by sizeof. */ +/* The size of a `float', as computed by sizeof. */ #undef SIZEOF_FLOAT -/* The size of `int', as computed by sizeof. */ +/* The size of a `int', as computed by sizeof. */ #undef SIZEOF_INT -/* The size of `long', as computed by sizeof. */ +/* The size of a `long', as computed by sizeof. */ #undef SIZEOF_LONG -/* The size of `long long', as computed by sizeof. */ +/* The size of a `long long', as computed by sizeof. */ #undef SIZEOF_LONG_LONG -/* The size of `short', as computed by sizeof. */ +/* The size of a `short', as computed by sizeof. */ #undef SIZEOF_SHORT -/* The size of `void*', as computed by sizeof. */ +/* The size of a `void*', as computed by sizeof. */ #undef SIZEOF_VOIDP /* Define to 1 if you have the ANSI C header files. */ @@ -595,5 +604,5 @@ #undef inline #endif -/* Define to `unsigned int' if does not define. */ +/* Define to `unsigned' if does not define. */ #undef size_t diff --git a/Source/NSPathUtilities.m b/Source/NSPathUtilities.m index ef7a5367c..ff30951ae 100644 --- a/Source/NSPathUtilities.m +++ b/Source/NSPathUtilities.m @@ -149,6 +149,10 @@ static NSString *tempDir = nil; /* user's temporary directory */ /* The following list entirely describe our filesystem configuration. */ static NSString *gnustepMakefiles = nil; +static NSString *gnustepSystemUsersDir = nil; +static NSString *gnustepNetworkUsersDir = nil; +static NSString *gnustepLocalUsersDir = nil; + static NSString *gnustepSystemApps = nil; static NSString *gnustepSystemAdminApps = nil; static NSString *gnustepSystemWebApps = nil; @@ -324,6 +328,10 @@ static void ExtractValuesFromConfig(NSDictionary *config) ASSIGN_PATH(gnustepMakefiles, c, @"GNUSTEP_MAKEFILES"); + ASSIGN_PATH(gnustepSystemUsersDir, c, @"GNUSTEP_SYSTEM_USERS_DIR"); + ASSIGN_PATH(gnustepNetworkUsersDir, c, @"GNUSTEP_NETWORK_USERS_DIR"); + ASSIGN_PATH(gnustepLocalUsersDir, c, @"GNUSTEP_LOCAL_USERS_DIR"); + ASSIGN_PATH(gnustepSystemApps, c, @"GNUSTEP_SYSTEM_APPS"); ASSIGN_PATH(gnustepSystemAdminApps, c, @"GNUSTEP_SYSTEM_ADMIN_APPS"); ASSIGN_PATH(gnustepSystemWebApps, c, @"GNUSTEP_SYSTEM_WEB_APPS"); @@ -563,6 +571,10 @@ static void ExtractValuesFromConfig(NSDictionary *config) ASSIGN_DEFAULT_PATH(gnustepLocalDocumentationInfo, @GNUSTEP_TARGET_LOCAL_DOC_INFO); ASSIGN_DEFAULT_PATH(gnustepMakefiles, @GNUSTEP_TARGET_MAKEFILES); + + ASSIGN_DEFAULT_PATH(gnustepSystemUsersDir, @GNUSTEP_TARGET_SYSTEM_USERS_DIR); + ASSIGN_DEFAULT_PATH(gnustepNetworkUsersDir, @GNUSTEP_TARGET_NETWORK_USERS_DIR); + ASSIGN_DEFAULT_PATH(gnustepLocalUsersDir, @GNUSTEP_TARGET_LOCAL_USERS_DIR); } NSMutableDictionary* @@ -795,6 +807,10 @@ static void ShutdownPathUtilities(void) DESTROY(gnustepMakefiles); + DESTROY(gnustepSystemUsersDir); + DESTROY(gnustepNetworkUsersDir); + DESTROY(gnustepLocalUsersDir); + DESTROY(gnustepSystemApps); DESTROY(gnustepSystemAdminApps); DESTROY(gnustepSystemWebApps); @@ -1745,10 +1761,13 @@ if (domainMask & mask) \ case NSUserDirectory: { - if (domainMask & NSUserDomainMask) - { - [paths addObject: gnustepUserHome]; - } + /* This is the directory in which user directories are located. + * You can not have user directories in your own user directory, + * so NSUserDomainMask will always return ''. + */ + ADD_PLATFORM_PATH(NSLocalDomainMask, gnustepLocalUsersDir); + ADD_PLATFORM_PATH(NSNetworkDomainMask, gnustepNetworkUsersDir); + ADD_PLATFORM_PATH(NSSystemDomainMask, gnustepSystemUsersDir); } break; diff --git a/configure b/configure index c49e1e7cb..eba48eae0 100755 --- a/configure +++ b/configure @@ -1710,6 +1710,10 @@ fi if test x"$GNUSTEP_MAKEFILES" = x""; then GNUSTEP_MAKEFILES=$GNUSTEP_SYSTEM_ROOT/Library/Makefiles; fi +if test x"$GNUSTEP_SYSTEM_USERS_DIR" = x""; then GNUSTEP_SYSTEM_USERS_DIR=/home; fi +if test x"$GNUSTEP_NETWORK_USERS_DIR" = x""; then GNUSTEP_NETWORK_USERS_DIR=/home; fi +if test x"$GNUSTEP_LOCAL_USERS_DIR" = x""; then GNUSTEP_LOCAL_USERS_DIR=/home; fi + if test x"$GNUSTEP_SYSTEM_APPS" = x""; then GNUSTEP_SYSTEM_APPS=$GNUSTEP_SYSTEM_ROOT/Applications; fi if test x"$GNUSTEP_SYSTEM_ADMIN_APPS" = x""; then GNUSTEP_SYSTEM_ADMIN_APPS=$GNUSTEP_SYSTEM_ROOT/Applications/Admin; fi if test x"$GNUSTEP_SYSTEM_WEB_APPS" = x""; then GNUSTEP_SYSTEM_WEB_APPS=$GNUSTEP_SYSTEM_ROOT/WebApplications; fi @@ -1769,6 +1773,16 @@ if test x"$GNUSTEP_USER_DIR_DOC_INFO" = x""; then GNUSTEP_USER_DIR_DOC_INFO=$GNU case "$target_os" in mingw*) GNUSTEP_BASE_PATH="$GNUSTEP_SYSTEM_TOOLS" + + # TODO: Improve this hack. + # According to Wikipedia, this is the default for Windows 2000, + # Windows XP and Windows Server 2003. For Windows Vista this will + # change to C:\Users. The directory name needs to be localized though + # (and the disk may need changing as well ?). + GNUSTEP_SYSTEM_USERS_DIR="C:\Documents and Settings" + GNUSTEP_NETWORK_USERS_DIR="C:\Documents and Settings" + GNUSTEP_LOCAL_USERS_DIR="C:\Documents and Settings" + GNUSTEP_SYSTEM_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_APPS` GNUSTEP_SYSTEM_ADMIN_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_ADMIN_APPS` GNUSTEP_SYSTEM_WEB_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_WEB_APPS` @@ -2013,6 +2027,19 @@ echo $ECHO_N "checking for User Man Documentation directory... $ECHO_C" >&6 echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_DOC_MAN" >&5 echo "${ECHO_T}$GNUSTEP_USER_DIR_DOC_MAN" >&6 +echo "$as_me:$LINENO: checking for System User directory" >&5 +echo $ECHO_N "checking for System User directory... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_USERS_DIR" >&5 +echo "${ECHO_T}$GNUSTEP_SYSTEM_USERS_DIR" >&6 +echo "$as_me:$LINENO: checking for Network User directory" >&5 +echo $ECHO_N "checking for Network User directory... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_USERS_DIR" >&5 +echo "${ECHO_T}$GNUSTEP_NETWORK_USERS_DIR" >&6 +echo "$as_me:$LINENO: checking for Local User directory" >&5 +echo $ECHO_N "checking for Local User directory... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_USERS_DIR" >&5 +echo "${ECHO_T}$GNUSTEP_LOCAL_USERS_DIR" >&6 + # # Set the default configuration file values in config.h to be hard-coded # into NSPathUtilities.m @@ -2368,6 +2395,26 @@ cat >>confdefs.h <<_ACEOF _ACEOF +GNUSTEP_TARGET_SYSTEM_USERS_DIR=`echo $GNUSTEP_TARGET_SYSTEM_USERS_DIR|sed -e 's/\\\\/\\\\\\\\/g'` + +cat >>confdefs.h <<_ACEOF +#define GNUSTEP_TARGET_SYSTEM_USERS_DIR "$GNUSTEP_TARGET_SYSTEM_USERS_DIR" +_ACEOF + +GNUSTEP_TARGET_NETWORK_USERS_DIR=`echo $GNUSTEP_TARGET_NETWORK_USERS_DIR|sed -e 's/\\\\/\\\\\\\\/g'` + +cat >>confdefs.h <<_ACEOF +#define GNUSTEP_TARGET_NETWORK_USERS_DIR "$GNUSTEP_TARGET_NETWORK_USERS_DIR" +_ACEOF + +GNUSTEP_TARGET_LOCAL_USERS_DIR=`echo $GNUSTEP_TARGET_LOCAL_USERS_DIR|sed -e 's/\\\\/\\\\\\\\/g'` + +cat >>confdefs.h <<_ACEOF +#define GNUSTEP_TARGET_LOCAL_USERS_DIR "$GNUSTEP_TARGET_LOCAL_USERS_DIR" +_ACEOF + + + #------------------------------------------------------------------------------ # Now we have finished configuring the default GNUstep filesystem setup of # the target. All GNUstep variables from now on are the ones used to build diff --git a/configure.ac b/configure.ac index 8d3978194..5cb3b83e0 100644 --- a/configure.ac +++ b/configure.ac @@ -275,6 +275,10 @@ fi if test x"$GNUSTEP_MAKEFILES" = x""; then GNUSTEP_MAKEFILES=$GNUSTEP_SYSTEM_ROOT/Library/Makefiles; fi +if test x"$GNUSTEP_SYSTEM_USERS_DIR" = x""; then GNUSTEP_SYSTEM_USERS_DIR=/home; fi +if test x"$GNUSTEP_NETWORK_USERS_DIR" = x""; then GNUSTEP_NETWORK_USERS_DIR=/home; fi +if test x"$GNUSTEP_LOCAL_USERS_DIR" = x""; then GNUSTEP_LOCAL_USERS_DIR=/home; fi + if test x"$GNUSTEP_SYSTEM_APPS" = x""; then GNUSTEP_SYSTEM_APPS=$GNUSTEP_SYSTEM_ROOT/Applications; fi if test x"$GNUSTEP_SYSTEM_ADMIN_APPS" = x""; then GNUSTEP_SYSTEM_ADMIN_APPS=$GNUSTEP_SYSTEM_ROOT/Applications/Admin; fi if test x"$GNUSTEP_SYSTEM_WEB_APPS" = x""; then GNUSTEP_SYSTEM_WEB_APPS=$GNUSTEP_SYSTEM_ROOT/WebApplications; fi @@ -334,6 +338,16 @@ if test x"$GNUSTEP_USER_DIR_DOC_INFO" = x""; then GNUSTEP_USER_DIR_DOC_INFO=$GNU case "$target_os" in mingw*) GNUSTEP_BASE_PATH="$GNUSTEP_SYSTEM_TOOLS" + + # TODO: Improve this hack. + # According to Wikipedia, this is the default for Windows 2000, + # Windows XP and Windows Server 2003. For Windows Vista this will + # change to C:\Users. The directory name needs to be localized though + # (and the disk may need changing as well ?). + GNUSTEP_SYSTEM_USERS_DIR="C:\Documents and Settings" + GNUSTEP_NETWORK_USERS_DIR="C:\Documents and Settings" + GNUSTEP_LOCAL_USERS_DIR="C:\Documents and Settings" + GNUSTEP_SYSTEM_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_APPS` GNUSTEP_SYSTEM_ADMIN_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_ADMIN_APPS` GNUSTEP_SYSTEM_WEB_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_WEB_APPS` @@ -481,6 +495,13 @@ AC_MSG_RESULT($GNUSTEP_USER_DIR_DOC_INFO) AC_MSG_CHECKING([for User Man Documentation directory]) AC_MSG_RESULT($GNUSTEP_USER_DIR_DOC_MAN) +AC_MSG_CHECKING([for System User directory]) +AC_MSG_RESULT($GNUSTEP_SYSTEM_USERS_DIR) +AC_MSG_CHECKING([for Network User directory]) +AC_MSG_RESULT($GNUSTEP_NETWORK_USERS_DIR) +AC_MSG_CHECKING([for Local User directory]) +AC_MSG_RESULT($GNUSTEP_LOCAL_USERS_DIR) + # # Set the default configuration file values in config.h to be hard-coded # into NSPathUtilities.m @@ -738,6 +759,20 @@ AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_DOC_INFO, "$GNUSTEP_USER_DIR_DOC_INFO", [Built in default value for GNUstep user_dir info documentation]) +GNUSTEP_TARGET_SYSTEM_USERS_DIR=`echo $GNUSTEP_TARGET_SYSTEM_USERS_DIR|sed -e 's/\\\\/\\\\\\\\/g'` +AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_USERS_DIR, + "$GNUSTEP_TARGET_SYSTEM_USERS_DIR", + [Built in default value for GNUstep System Users directory]) +GNUSTEP_TARGET_NETWORK_USERS_DIR=`echo $GNUSTEP_TARGET_NETWORK_USERS_DIR|sed -e 's/\\\\/\\\\\\\\/g'` +AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_USERS_DIR, + "$GNUSTEP_TARGET_NETWORK_USERS_DIR", + [Built in default value for GNUstep Network Users directory]) +GNUSTEP_TARGET_LOCAL_USERS_DIR=`echo $GNUSTEP_TARGET_LOCAL_USERS_DIR|sed -e 's/\\\\/\\\\\\\\/g'` +AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_USERS_DIR, + "$GNUSTEP_TARGET_LOCAL_USERS_DIR", + [Built in default value for GNUstep Local Users directory]) + + #------------------------------------------------------------------------------ # Now we have finished configuring the default GNUstep filesystem setup of # the target. All GNUstep variables from now on are the ones used to build