]>
git.saurik.com Git - wxWidgets.git/blob - src/unix/stdpaths.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: unix/stdpaths.cpp
3 // Purpose: wxStandardPaths implementation for Unix 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"
31 #include "wx/filename.h"
33 #include "wx/stdpaths.h"
39 // ============================================================================
40 // wxStandardPaths implementation
41 // ============================================================================
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 void wxStandardPaths::SetInstallPrefix(const wxString
& prefix
)
52 wxString
wxStandardPaths::GetInstallPrefix() const
54 if ( m_prefix
.empty() )
56 wxStandardPaths
*self
= wx_const_cast(wxStandardPaths
*, this);
59 // under Linux, we can get location of the executable
61 if ( readlink("/proc/self/exe", buf
, WXSIZEOF(buf
)) != -1 )
63 wxString
exe(buf
, wxConvLibc
);
65 // consider that we're in the last "bin" subdirectory of our prefix
66 wxString
basename(wxString(wxTheApp
->argv
[0]).AfterLast(_T('/')));
67 size_t pos
= exe
.find(_T("/bin/") + basename
);
68 if ( pos
!= wxString::npos
)
70 self
->m_prefix
.assign(exe
, 0, pos
);
74 if ( m_prefix
.empty() )
77 self
->m_prefix
= _T("/usr/local");
84 // ----------------------------------------------------------------------------
86 // ----------------------------------------------------------------------------
88 wxString
wxStandardPaths::GetConfigDir() const
93 wxString
wxStandardPaths::GetUserConfigDir() const
95 return wxFileName::GetHomeDir();
98 wxString
wxStandardPaths::GetDataDir() const
100 return AppendAppName(GetInstallPrefix() + _T("/share"));
103 wxString
wxStandardPaths::GetLocalDataDir() const
105 return AppendAppName(_T("/etc"));
108 wxString
wxStandardPaths::GetUserDataDir() const
110 return AppendAppName(wxFileName::GetHomeDir() + _T("/."));
113 wxString
wxStandardPaths::GetPluginsDir() const