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
#include <pwd.h> /* for get home without use getenv() */
45
#include <limits.h> /* for PATH_MAX */
48
static const char *static_path = PREFIX "/share";
50
static const char *static_path = NULL;
53
GHOST_SystemPathsX11::GHOST_SystemPathsX11()
57
GHOST_SystemPathsX11::~GHOST_SystemPathsX11()
61
const GHOST_TUns8 *GHOST_SystemPathsX11::getSystemDir(int, const char *versionstr) const
63
/* XXX On Debian ignore versionstr when building the system path */
66
/* no prefix assumes a portable build which only uses bundled scripts */
68
static char system_path[PATH_MAX];
69
snprintf(system_path, sizeof(system_path), "%s/blender/%s", static_path, versionstr);
70
return (GHOST_TUns8 *)system_path;
76
const GHOST_TUns8 *GHOST_SystemPathsX11::getUserDir(int version, const char *versionstr) const
78
static char user_path[PATH_MAX];
80
/* in blender 2.64, we migrate to XDG. to ensure the copy previous settings
81
* operator works we give a different path depending on the requested version */
83
const char *home = getenv("HOME");
86
snprintf(user_path, sizeof(user_path), "%s/.blender/%s", home, versionstr);
87
return (GHOST_TUns8 *)user_path;
93
const char *home = getenv("XDG_CONFIG_HOME");
96
snprintf(user_path, sizeof(user_path), "%s/blender/%s", home, versionstr);
99
home = getenv("HOME");
102
home = getpwuid(getuid())->pw_dir;
104
snprintf(user_path, sizeof(user_path), "%s/.config/blender/%s", home, versionstr);
107
return (const GHOST_TUns8 *)user_path;
111
const GHOST_TUns8 *GHOST_SystemPathsX11::getBinaryDir() const
116
void GHOST_SystemPathsX11::addToSystemRecentFiles(const char *filename) const
118
/* XXXXX TODO: Implementation for X11 if possible */