forked from enlightenment/efl
eina: add crosss platforme API to retrieve tmp and home directories from environment.
@feature No tests added as it is highly dependent on the system and it would make little sens. Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
3a6ccab3ad
commit
dbc6cbb953
|
@ -89,7 +89,8 @@ lib/eina/eina_thread_queue.h \
|
|||
lib/eina/eina_matrix.h \
|
||||
lib/eina/eina_quad.h \
|
||||
lib/eina/eina_crc.h \
|
||||
lib/eina/eina_evlog.h
|
||||
lib/eina/eina_evlog.h \
|
||||
lib/eina/eina_util.h
|
||||
|
||||
lib_eina_libeina_la_SOURCES = \
|
||||
lib/eina/eina_abi.c \
|
||||
|
@ -150,6 +151,7 @@ lib/eina/eina_tmpstr.c \
|
|||
lib/eina/eina_unicode.c \
|
||||
lib/eina/eina_ustrbuf.c \
|
||||
lib/eina/eina_ustringshare.c \
|
||||
lib/eina/eina_util.c \
|
||||
lib/eina/eina_value.c \
|
||||
lib/eina/eina_value_util.c \
|
||||
lib/eina/eina_xattr.c \
|
||||
|
|
|
@ -265,6 +265,7 @@ extern "C" {
|
|||
#include <eina_matrix.h>
|
||||
#include <eina_crc.h>
|
||||
#include <eina_evlog.h>
|
||||
#include <eina_util.h>
|
||||
|
||||
#undef EAPI
|
||||
#define EAPI
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/* EINA - EFL data type library
|
||||
* Copyright (C) 2015 Vincent Torri
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "eina_config.h"
|
||||
#include "eina_private.h"
|
||||
#include "eina_tmpstr.h"
|
||||
|
||||
/*============================================================================*
|
||||
* Local *
|
||||
*============================================================================*/
|
||||
|
||||
|
||||
/*============================================================================*
|
||||
* Global *
|
||||
*============================================================================*/
|
||||
|
||||
|
||||
/*============================================================================*
|
||||
* API *
|
||||
*============================================================================*/
|
||||
|
||||
EAPI Eina_Tmpstr *
|
||||
eina_environment_home_get(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char *home;
|
||||
|
||||
home = getenv("USERPROFILE");
|
||||
if (!home) home = getenv("WINDIR");
|
||||
if (!home) home = "C:\\";
|
||||
|
||||
return eina_tmpstr_add(home);
|
||||
#else
|
||||
return eina_tmpstr_add(getenv("HOME"));
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI Eina_Tmpstr *
|
||||
eina_environment_tmp_get(void)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
#ifdef _WIN32
|
||||
tmp = getenv("TMP");
|
||||
if (!tmp) tmp = getenv("TEMP");
|
||||
if (!tmp) tmp = getenv("USERPROFILE");
|
||||
if (!tmp) tmp = getenv("WINDIR");
|
||||
if (!tmp) tmp = "C:\\";
|
||||
|
||||
return eina_tmpstr_add(tmp);
|
||||
#else
|
||||
tmp = getenv("TMPDIR");
|
||||
if (!tmp) tmp = getenv("XDG_RUNTIME_DIR");
|
||||
if (!tmp) tmp = "/tmp";
|
||||
|
||||
return eina_tmpstr_add(tmp);
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/* EINA - EFL data type library
|
||||
* Copyright (C) 2015 Vincent Torri
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EINA_UTIL_H_
|
||||
#define EINA_UTIL_H_
|
||||
|
||||
/**
|
||||
* @addtogroup Eina_Tools_Group Tools
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Return the content of the environment refered by HOME on this system.
|
||||
* @return A temporary string to the content refered by HOME on this system.
|
||||
*
|
||||
* @note The result of this call is highly system dependent and you better use
|
||||
* it instead of the naive getenv("HOME").
|
||||
*/
|
||||
EAPI Eina_Tmpstr *eina_environment_home_get(void);
|
||||
|
||||
/**
|
||||
* @brief Return the content of the environment refered as TMPDIR on this system.
|
||||
* @return A temporary string to the content refered by TMPDIR on this system.
|
||||
*
|
||||
* @note The result of this call is highly system dependent and you better use
|
||||
* it instead of the naive getenv("TMPDIR").
|
||||
*/
|
||||
EAPI Eina_Tmpstr *eina_environment_tmp_get(void);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue