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 #if defined(__WXMAC__)
42 #include "wx/mac/private.h"
45 // ============================================================================
46 // wxStandardPaths implementation
47 // ============================================================================
49 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
53 void wxStandardPaths::SetInstallPrefix(const wxString
& prefix
)
58 wxString
wxStandardPaths::GetInstallPrefix() const
60 if ( m_prefix
.empty() )
62 wxStandardPaths
*pathPtr
= wx_const_cast(wxStandardPaths
*, this);
65 // under Linux, we can try to infer the prefix from the location of the
68 int result
= readlink("/proc/self/exe", buf
, WXSIZEOF(buf
) - sizeof(char));
71 buf
[result
] = '\0'; // readlink() doesn't NUL-terminate the buffer
73 wxString
exeStr(buf
, wxConvLibc
);
75 // consider that we're in the last "bin" subdirectory of our prefix
76 wxString
basename(wxString(wxTheApp
->argv
[0]).AfterLast(_T('/')));
77 size_t pos
= exeStr
.find(wxT("/bin/") + basename
);
78 if ( pos
!= wxString::npos
)
79 pathPtr
->m_prefix
.assign(exeStr
, 0, pos
);
83 if ( m_prefix
.empty() )
86 pathPtr
->m_prefix
= wxT("/sys$system");
88 pathPtr
->m_prefix
= wxT("/usr/local");
96 // ----------------------------------------------------------------------------
98 // ----------------------------------------------------------------------------
100 wxString
wxStandardPaths::GetConfigDir() const
103 return _T("/sys$manager");
109 wxString
wxStandardPaths::GetUserConfigDir() const
111 return wxFileName::GetHomeDir();
114 wxString
wxStandardPaths::GetDataDir() const
117 return AppendAppName(GetInstallPrefix() + _T("/sys$share"));
119 return AppendAppName(GetInstallPrefix() + _T("/share"));
123 wxString
wxStandardPaths::GetLocalDataDir() const
126 return AppendAppName(_T("/sys$manager"));
128 return AppendAppName(_T("/etc"));
132 wxString
wxStandardPaths::GetUserDataDir() const
135 return wxFileName::GetHomeDir();
136 #elif defined(__WXMAC__)
137 return AppendAppName(wxMacFindFolder((short) kUserDomain
, kApplicationSupportFolderType
, kDontCreateFolder
));
139 return AppendAppName(wxFileName::GetHomeDir() + _T("/."));
143 wxString
wxStandardPaths::GetPluginsDir() const
148 #endif // wxUSE_STDPATHS