]>
git.saurik.com Git - wxWidgets.git/blob - src/unix/stdpaths.cpp
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
*self
= wx_const_cast(wxStandardPaths
*, this);
61 // under Linux, we can get location of the executable
63 if ( readlink("/proc/self/exe", buf
, WXSIZEOF(buf
)) != -1 )
65 wxString
exe(buf
, wxConvLibc
);
67 // consider that we're in the last "bin" subdirectory of our prefix
68 wxString
basename(wxString(wxTheApp
->argv
[0]).AfterLast(_T('/')));
69 size_t pos
= exe
.find(_T("/bin/") + basename
);
70 if ( pos
!= wxString::npos
)
72 self
->m_prefix
.assign(exe
, 0, pos
);
76 if ( m_prefix
.empty() )
80 self
->m_prefix
= _T("/sys$system");
82 self
->m_prefix
= _T("/usr/local");
90 // ----------------------------------------------------------------------------
92 // ----------------------------------------------------------------------------
94 wxString
wxStandardPaths::GetConfigDir() const
97 return _T("/sys$manager");
103 wxString
wxStandardPaths::GetUserConfigDir() const
105 return wxFileName::GetHomeDir();
108 wxString
wxStandardPaths::GetDataDir() const
111 return AppendAppName(GetInstallPrefix() + _T("/sys$share"));
113 return AppendAppName(GetInstallPrefix() + _T("/share"));
117 wxString
wxStandardPaths::GetLocalDataDir() const
120 return AppendAppName(_T("/sys$manager"));
122 return AppendAppName(_T("/etc"));
126 wxString
wxStandardPaths::GetUserDataDir() const
129 return wxFileName::GetHomeDir();
131 return AppendAppName(wxFileName::GetHomeDir() + _T("/."));
135 wxString
wxStandardPaths::GetPluginsDir() const
140 #endif // wxUSE_STDPATHS