]>
git.saurik.com Git - wxWidgets.git/blob - src/unix/stdpaths.cpp
9b95c0f884adefb562df3fc8e88d95dc0002f648
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: unix/stdpaths.cpp
3 // Purpose: wxStandardPaths implementation for Unix & OpenVMS systems
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2004 Vadim Zeitlin <vadim@wxwindows.org>
9 // License: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
33 #include "wx/filename.h"
35 #include "wx/stdpaths.h"
37 #if defined( __LINUX__ ) || defined( __VMS )
41 // ============================================================================
42 // common VMS/Unix part of wxStandardPaths implementation
43 // ============================================================================
45 void wxStandardPaths::SetInstallPrefix(const wxString
& prefix
)
50 wxString
wxStandardPaths::GetUserConfigDir() const
52 return wxFileName::GetHomeDir();
55 wxString
wxStandardPaths::GetPluginsDir() const
60 // ============================================================================
61 // wxStandardPaths implementation for VMS
62 // ============================================================================
66 wxString
wxStandardPaths::GetInstallPrefix() const
68 if ( m_prefix
.empty() )
70 wx_const_cast(wxStandardPaths
*, this)->m_prefix
= wxT("/sys$system");
74 wxString
wxStandardPaths::GetConfigDir() const
76 return _T("/sys$manager");
79 wxString
wxStandardPaths::GetDataDir() const
81 return AppendAppName(GetInstallPrefix() + _T("/sys$share"));
84 wxString
wxStandardPaths::GetLocalDataDir() const
86 return AppendAppName(_T("/sys$manager"));
89 wxString
wxStandardPaths::GetUserDataDir() const
91 return wxFileName::GetHomeDir();
96 // ============================================================================
97 // wxStandardPaths implementation for Unix
98 // ============================================================================
100 wxString
wxStandardPaths::GetInstallPrefix() const
102 if ( m_prefix
.empty() )
104 wxStandardPaths
*pathPtr
= wx_const_cast(wxStandardPaths
*, this);
107 // under Linux, we can try to infer the prefix from the location of the
110 int result
= readlink("/proc/self/exe", buf
, WXSIZEOF(buf
) - sizeof(char));
113 buf
[result
] = '\0'; // readlink() doesn't NUL-terminate the buffer
115 const wxString
exeStr(buf
, wxConvLibc
);
117 // consider that we're in the last "bin" subdirectory of our prefix
118 size_t pos
= exeStr
.rfind(wxT("/bin/"));
119 if ( pos
!= wxString::npos
)
120 pathPtr
->m_prefix
.assign(exeStr
, 0, pos
);
124 if ( m_prefix
.empty() )
126 pathPtr
->m_prefix
= wxT("/usr/local");
133 // ----------------------------------------------------------------------------
135 // ----------------------------------------------------------------------------
137 wxString
wxStandardPaths::GetConfigDir() const
142 wxString
wxStandardPaths::GetDataDir() const
144 return AppendAppName(GetInstallPrefix() + _T("/share"));
147 wxString
wxStandardPaths::GetLocalDataDir() const
149 return AppendAppName(_T("/etc"));
152 wxString
wxStandardPaths::GetUserDataDir() const
154 return AppendAppName(wxFileName::GetHomeDir() + _T("/."));
157 #endif // __VMS/!__VMS
159 #endif // wxUSE_STDPATHS