Add two convenience functions in order to make sure we get these
environment variables in a consistent manner. These functions retrieve the user and the temporary directories (based on the system). This commit was SVN r17815.
Этот коммит содержится в:
родитель
2e8a316ae6
Коммит
210631962c
@ -217,3 +217,27 @@ int opal_unsetenv(const char *name, char ***env)
|
||||
return (found) ? OPAL_SUCCESS : OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
const char* opal_tmp_directory( void )
|
||||
{
|
||||
const char* str;
|
||||
|
||||
if( NULL == (str = getenv("TMPDIR")) )
|
||||
if( NULL == (str = getenv("TEMP")) )
|
||||
if( NULL == (str = getenv("TMP")) )
|
||||
if( NULL == (str = opal_home_directory()) )
|
||||
str = ".";
|
||||
return str;
|
||||
}
|
||||
|
||||
const char* opal_home_directory( void )
|
||||
{
|
||||
char* home = getenv("HOME");
|
||||
|
||||
#if defined(__WINDOWS__)
|
||||
if( NULL == home )
|
||||
home = getenv("USERPROFILE");
|
||||
#endif /* defined(__WINDOWS__) */
|
||||
|
||||
return home;
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,12 @@ OPAL_DECLSPEC int opal_setenv(const char *name, const char *value,
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_unsetenv(const char *name, char ***env) __opal_attribute_nonnull__(1);
|
||||
|
||||
/* A consistent way to retrieve the home and tmp directory on all supported
|
||||
* platforms.
|
||||
*/
|
||||
OPAL_DECLSPEC const char* opal_home_directory( void );
|
||||
OPAL_DECLSPEC const char* opal_tmp_directory( void );
|
||||
|
||||
/* Some care is needed with environ on OS X when dealing with shared
|
||||
libraries. Handle that care here... */
|
||||
#if !defined(__WINDOWS__)
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user