]>
git.saurik.com Git - wxWidgets.git/blob - src/unix/stdpaths.cpp
543294e1476989af13174b6d1b8b2cfabbc478d1
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 // ============================================================================
56 // wxStandardPaths implementation for VMS
57 // ============================================================================
61 wxString
wxStandardPaths::GetInstallPrefix() const
63 if ( m_prefix
.empty() )
65 wx_const_cast(wxStandardPaths
*, this)->m_prefix
= wxT("/sys$system");
71 wxString
wxStandardPaths::GetConfigDir() const
73 return _T("/sys$manager");
76 wxString
wxStandardPaths::GetDataDir() const
78 return AppendAppName(GetInstallPrefix() + _T("/sys$share"));
81 wxString
wxStandardPaths::GetLocalDataDir() const
83 return AppendAppName(_T("/sys$manager"));
86 wxString
wxStandardPaths::GetUserDataDir() const
88 return wxFileName::GetHomeDir();
91 wxString
wxStandardPaths::GetPluginsDir() const
93 return wxString(); // TODO: this is wrong, it should return something
98 // ============================================================================
99 // wxStandardPaths implementation for Unix
100 // ============================================================================
102 wxString
wxStandardPaths::GetInstallPrefix() const
104 if ( m_prefix
.empty() )
106 wxStandardPaths
*pathPtr
= wx_const_cast(wxStandardPaths
*, this);
109 // under Linux, we can try to infer the prefix from the location of the
112 int result
= readlink("/proc/self/exe", buf
, WXSIZEOF(buf
) - sizeof(char));
115 buf
[result
] = '\0'; // readlink() doesn't NUL-terminate the buffer
117 const wxString
exeStr(buf
, wxConvLibc
);
119 // consider that we're in the last "bin" subdirectory of our prefix
120 size_t pos
= exeStr
.rfind(wxT("/bin/"));
121 if ( pos
!= wxString::npos
)
122 pathPtr
->m_prefix
.assign(exeStr
, 0, pos
);
126 if ( m_prefix
.empty() )
128 pathPtr
->m_prefix
= wxT("/usr/local");
135 // ----------------------------------------------------------------------------
137 // ----------------------------------------------------------------------------
139 wxString
wxStandardPaths::GetConfigDir() const
144 wxString
wxStandardPaths::GetDataDir() const
146 return AppendAppName(GetInstallPrefix() + _T("/share"));
149 wxString
wxStandardPaths::GetLocalDataDir() const
151 return AppendAppName(_T("/etc"));
154 wxString
wxStandardPaths::GetUserDataDir() const
156 return AppendAppName(wxFileName::GetHomeDir() + _T("/."));
159 wxString
wxStandardPaths::GetPluginsDir() const
161 return AppendAppName(GetInstallPrefix() + _T("/lib"));
164 #endif // __VMS/!__VMS
166 #endif // wxUSE_STDPATHS