]>
git.saurik.com Git - wxWidgets.git/blob - src/unix/stdpaths.cpp
ba1c3f3016f2efc6b4009c5bfc3b3b449f9d34e3
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 const wxString
exeStr(buf
, wxConvLibc
);
71 // consider that we're in the last "bin" subdirectory of our prefix
72 size_t pos
= exeStr
.rfind(wxT("/bin/"));
73 if ( pos
!= wxString::npos
)
74 pathPtr
->m_prefix
.assign(exeStr
, 0, pos
);
78 if ( m_prefix
.empty() )
81 pathPtr
->m_prefix
= wxT("/sys$system");
83 pathPtr
->m_prefix
= wxT("/usr/local");
91 // ----------------------------------------------------------------------------
93 // ----------------------------------------------------------------------------
95 wxString
wxStandardPaths::GetConfigDir() const
98 return _T("/sys$manager");
104 wxString
wxStandardPaths::GetUserConfigDir() const
106 return wxFileName::GetHomeDir();
109 wxString
wxStandardPaths::GetDataDir() const
112 return AppendAppName(GetInstallPrefix() + _T("/sys$share"));
114 return AppendAppName(GetInstallPrefix() + _T("/share"));
118 wxString
wxStandardPaths::GetLocalDataDir() const
121 return AppendAppName(_T("/sys$manager"));
123 return AppendAppName(_T("/etc"));
127 wxString
wxStandardPaths::GetUserDataDir() const
130 return wxFileName::GetHomeDir();
132 return AppendAppName(wxFileName::GetHomeDir() + _T("/."));
136 wxString
wxStandardPaths::GetPluginsDir() const
141 #endif // wxUSE_STDPATHS