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 const wxString
exeStr(buf
, wxConvLibc
);
75 // consider that we're in the last "bin" subdirectory of our prefix
76 size_t pos
= exeStr
.rfind(wxT("/bin/"));
77 if ( pos
!= wxString
::npos
)
78 pathPtr
->m_prefix
.assign(exeStr
, 0, pos
);
82 if ( m_prefix
.empty() )
85 pathPtr
->m_prefix
= wxT("/sys$system");
87 pathPtr
->m_prefix
= wxT("/usr/local");
95 // ----------------------------------------------------------------------------
97 // ----------------------------------------------------------------------------
99 wxString wxStandardPaths
::GetConfigDir() const
102 return _T("/sys$manager");
108 wxString wxStandardPaths
::GetUserConfigDir() const
110 return wxFileName
::GetHomeDir();
113 wxString wxStandardPaths
::GetDataDir() const
116 return AppendAppName(GetInstallPrefix() + _T("/sys$share"));
118 return AppendAppName(GetInstallPrefix() + _T("/share"));
122 wxString wxStandardPaths
::GetLocalDataDir() const
125 return AppendAppName(_T("/sys$manager"));
127 return AppendAppName(_T("/etc"));
131 wxString wxStandardPaths
::GetUserDataDir() const
134 return wxFileName
::GetHomeDir();
135 #elif defined(__WXMAC__)
136 return AppendAppName(wxMacFindFolder((short) kUserDomain
, kApplicationSupportFolderType
, kDontCreateFolder
));
138 return AppendAppName(wxFileName
::GetHomeDir() + _T("/."));
142 wxString wxStandardPaths
::GetPluginsDir() const
147 #endif // wxUSE_STDPATHS