]>
git.saurik.com Git - wxWidgets.git/blob - src/unix/stdpaths.cpp
fbecba3600730cee85065f3db5af5ff078579fc8
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 // wxStandardPaths implementation
43 // ============================================================================
45 // ----------------------------------------------------------------------------
47 // ----------------------------------------------------------------------------
49 void wxStandardPaths::SetInstallPrefix(const wxString
& prefix
)
54 wxString
wxStandardPaths::GetInstallPrefix() const
56 if ( m_prefix
.empty() )
58 wxStandardPaths
*pathPtr
= wx_const_cast(wxStandardPaths
*, this);
61 // under Linux, we can try to infer the prefix from the location of the
64 int result
= readlink("/proc/self/exe", buf
, WXSIZEOF(buf
) - sizeof(char));
67 buf
[result
] = '\0'; // readlink() doesn't NUL-terminate the buffer
69 wxString
exeStr(buf
, wxConvLibc
);
71 // consider that we're in the last "bin" subdirectory of our prefix
72 wxString
basename(wxString(wxTheApp
->argv
[0]).AfterLast(_T('/')));
73 size_t pos
= exeStr
.find(wxT("/bin/") + basename
);
74 if ( pos
!= wxString::npos
)
75 pathPtr
->m_prefix
.assign(exeStr
, 0, pos
);
79 if ( m_prefix
.empty() )
82 pathPtr
->m_prefix
= wxT("/sys$system");
84 pathPtr
->m_prefix
= wxT("/usr/local");
92 // ----------------------------------------------------------------------------
94 // ----------------------------------------------------------------------------
96 wxString
wxStandardPaths::GetConfigDir() const
99 return _T("/sys$manager");
105 wxString
wxStandardPaths::GetUserConfigDir() const
107 return wxFileName::GetHomeDir();
110 wxString
wxStandardPaths::GetDataDir() const
113 return AppendAppName(GetInstallPrefix() + _T("/sys$share"));
115 return AppendAppName(GetInstallPrefix() + _T("/share"));
119 wxString
wxStandardPaths::GetLocalDataDir() const
122 return AppendAppName(_T("/sys$manager"));
124 return AppendAppName(_T("/etc"));
128 wxString
wxStandardPaths::GetUserDataDir() const
131 return wxFileName::GetHomeDir();
133 return AppendAppName(wxFileName::GetHomeDir() + _T("/."));
137 wxString
wxStandardPaths::GetPluginsDir() const
142 #endif // wxUSE_STDPATHS