2
* ***** BEGIN GPL LICENSE BLOCK *****
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
* The Original Code is Copyright (C) 2010 Blender Foundation.
19
* All rights reserved.
22
* Contributor(s): Blender Foundation
24
* ***** END GPL LICENSE BLOCK *****
27
/** \file ghost/intern/GHOST_SystemPathsX11.cpp
32
#include "GHOST_SystemPathsX11.h"
34
#include "GHOST_Debug.h"
41
#include <stdio.h> // for fprintf only
42
#include <cstdlib> // for exit
44
#ifdef WITH_XDG_USER_DIRS
45
# include <pwd.h> // for get home without use getenv()
46
# include <limits.h> // for PATH_MAX
50
static const char *static_path= PREFIX "/share";
52
static const char *static_path= NULL;
55
GHOST_SystemPathsX11::GHOST_SystemPathsX11()
59
GHOST_SystemPathsX11::~GHOST_SystemPathsX11()
63
const GHOST_TUns8* GHOST_SystemPathsX11::getSystemDir() const
65
/* no prefix assumes a portable build which only uses bundled scripts */
66
return (const GHOST_TUns8 *)static_path;
69
const GHOST_TUns8* GHOST_SystemPathsX11::getUserDir() const
71
#ifndef WITH_XDG_USER_DIRS
72
return (const GHOST_TUns8 *)getenv("HOME");
73
#else /* WITH_XDG_USER_DIRS */
74
const char *home= getenv("XDG_CONFIG_HOME");
77
return (const GHOST_TUns8 *)home;
80
static char user_path[PATH_MAX];
85
home= getpwuid(getuid())->pw_dir;
88
snprintf(user_path, sizeof(user_path), "%s/.config", home);
89
return (const GHOST_TUns8 *)user_path;
91
#endif /* WITH_XDG_USER_DIRS */
94
const GHOST_TUns8* GHOST_SystemPathsX11::getBinaryDir() const
99
void GHOST_SystemPathsX11::addToSystemRecentFiles(const char* filename) const
101
/* XXXXX TODO: Implementation for X11 if possible */