~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to intern/ghost/intern/GHOST_SystemPathsX11.cpp

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include <sys/time.h>
39
39
#include <unistd.h>
40
40
 
41
 
#include <stdio.h> // for fprintf only
42
 
#include <cstdlib> // for exit
 
41
#include <stdio.h>   /* for fprintf only */
 
42
#include <cstdlib>   /* for exit */
43
43
 
44
 
#ifdef WITH_XDG_USER_DIRS
45
 
#  include <pwd.h> // for get home without use getenv()
46
 
#  include <limits.h> // for PATH_MAX
47
 
#endif
 
44
#include <pwd.h>     /* for get home without use getenv() */
 
45
#include <limits.h>  /* for PATH_MAX */
48
46
 
49
47
#ifdef PREFIX
50
 
static const char *static_path= PREFIX "/lib";
 
48
static const char *static_path = PREFIX "/share";
51
49
#else
52
 
static const char *static_path= NULL;
 
50
static const char *static_path = NULL;
53
51
#endif
54
52
 
55
53
GHOST_SystemPathsX11::GHOST_SystemPathsX11()
60
58
{
61
59
}
62
60
 
63
 
const GHOST_TUns8* GHOST_SystemPathsX11::getSystemDir() const
 
61
const GHOST_TUns8 *GHOST_SystemPathsX11::getSystemDir(int, const char *versionstr) const
64
62
{
65
63
        /* no prefix assumes a portable build which only uses bundled scripts */
66
 
        return (const GHOST_TUns8 *)static_path;
 
64
        if (static_path) {
 
65
                static char system_path[PATH_MAX];
 
66
                snprintf(system_path, sizeof(system_path), "%s/blender/%s", static_path, versionstr);
 
67
                return (GHOST_TUns8 *)system_path;
 
68
        }
 
69
 
 
70
        return NULL;
67
71
}
68
72
 
69
 
const GHOST_TUns8* GHOST_SystemPathsX11::getUserDir() const
 
73
const GHOST_TUns8 *GHOST_SystemPathsX11::getUserDir(int version, const char *versionstr) const
70
74
{
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");
75
 
 
76
 
        if (home) {
77
 
                return (const GHOST_TUns8 *)home;
 
75
        static char user_path[PATH_MAX];
 
76
 
 
77
        /* in blender 2.64, we migrate to XDG. to ensure the copy previous settings
 
78
         * operator works we give a different path depending on the requested version */
 
79
        if (version < 264) {
 
80
                const char *home = getenv("HOME");
 
81
 
 
82
                if (home) {
 
83
                        snprintf(user_path, sizeof(user_path), "%s/.blender/%s", home, versionstr);
 
84
                        return (GHOST_TUns8 *)user_path;
 
85
                }
 
86
 
 
87
                return NULL;
78
88
        }
79
89
        else {
80
 
                static char user_path[PATH_MAX];
81
 
 
82
 
                home= getenv("HOME");
83
 
 
84
 
                if (home == NULL) {
85
 
                        home= getpwuid(getuid())->pw_dir;
86
 
                }
87
 
 
88
 
                snprintf(user_path, sizeof(user_path), "%s/.config", home);
 
90
                const char *home = getenv("XDG_CONFIG_HOME");
 
91
 
 
92
                if (home) {
 
93
                        snprintf(user_path, sizeof(user_path), "%s/blender/%s", home, versionstr);
 
94
                }
 
95
                else {
 
96
                        home = getenv("HOME");
 
97
 
 
98
                        if (home == NULL)
 
99
                                home = getpwuid(getuid())->pw_dir;
 
100
 
 
101
                        snprintf(user_path, sizeof(user_path), "%s/.config/blender/%s", home, versionstr);
 
102
                }
 
103
 
89
104
                return (const GHOST_TUns8 *)user_path;
90
105
        }
91
 
#endif /* WITH_XDG_USER_DIRS */
92
106
}
93
107
 
94
 
const GHOST_TUns8* GHOST_SystemPathsX11::getBinaryDir() const
 
108
const GHOST_TUns8 *GHOST_SystemPathsX11::getBinaryDir() const
95
109
{
96
110
        return NULL;
97
111
}
98
112
 
99
 
void GHOST_SystemPathsX11::addToSystemRecentFiles(const char* filename) const
 
113
void GHOST_SystemPathsX11::addToSystemRecentFiles(const char *filename) const
100
114
{
101
115
        /* XXXXX TODO: Implementation for X11 if possible */
102
116