]> git.saurik.com Git - wxWidgets.git/blob - src/unix/stdpaths.cpp
[ 1216436 ] cleanup 'shadow variable' warnings from gcc in headers.
[wxWidgets.git] / src / unix / stdpaths.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: unix/stdpaths.cpp
3 // Purpose: wxStandardPaths implementation for Unix & OpenVMS systems
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 2004-10-19
7 // RCS-ID: $Id$
8 // Copyright: (c) 2004 Vadim Zeitlin <vadim@wxwindows.org>
9 // License: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_STDPATHS
28
29 #ifndef WX_PRECOMP
30 #include "wx/app.h"
31 #endif //WX_PRECOMP
32
33 #include "wx/filename.h"
34
35 #include "wx/stdpaths.h"
36
37 #if defined( __LINUX__ ) || defined( __VMS )
38 #include <unistd.h>
39 #endif
40
41 // ============================================================================
42 // wxStandardPaths implementation
43 // ============================================================================
44
45 // ----------------------------------------------------------------------------
46 // prefix management
47 // ----------------------------------------------------------------------------
48
49 void wxStandardPaths::SetInstallPrefix(const wxString& prefix)
50 {
51 m_prefix = prefix;
52 }
53
54 wxString wxStandardPaths::GetInstallPrefix() const
55 {
56 if ( m_prefix.empty() )
57 {
58 wxStandardPaths *self = wx_const_cast(wxStandardPaths *, this);
59
60 #ifdef __LINUX__
61 // under Linux, we can get location of the executable
62 char buf[4096];
63 if ( readlink("/proc/self/exe", buf, WXSIZEOF(buf)) != -1 )
64 {
65 wxString exe(buf, wxConvLibc);
66
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 )
71 {
72 self->m_prefix.assign(exe, 0, pos);
73 }
74 }
75
76 if ( m_prefix.empty() )
77 #endif // __LINUX__
78 {
79 #ifdef __VMS
80 self->m_prefix = _T("/sys$system");
81 #else
82 self->m_prefix = _T("/usr/local");
83 #endif
84 }
85 }
86
87 return m_prefix;
88 }
89
90 // ----------------------------------------------------------------------------
91 // public functions
92 // ----------------------------------------------------------------------------
93
94 wxString wxStandardPaths::GetConfigDir() const
95 {
96 #ifdef __VMS
97 return _T("/sys$manager");
98 #else
99 return _T("/etc");
100 #endif
101 }
102
103 wxString wxStandardPaths::GetUserConfigDir() const
104 {
105 return wxFileName::GetHomeDir();
106 }
107
108 wxString wxStandardPaths::GetDataDir() const
109 {
110 #ifdef __VMS
111 return AppendAppName(GetInstallPrefix() + _T("/sys$share"));
112 #else
113 return AppendAppName(GetInstallPrefix() + _T("/share"));
114 #endif
115 }
116
117 wxString wxStandardPaths::GetLocalDataDir() const
118 {
119 #ifdef __VMS
120 return AppendAppName(_T("/sys$manager"));
121 #else
122 return AppendAppName(_T("/etc"));
123 #endif
124 }
125
126 wxString wxStandardPaths::GetUserDataDir() const
127 {
128 #ifdef __VMS
129 return wxFileName::GetHomeDir();
130 #else
131 return AppendAppName(wxFileName::GetHomeDir() + _T("/."));
132 #endif
133 }
134
135 wxString wxStandardPaths::GetPluginsDir() const
136 {
137 return wxString();
138 }
139
140 #endif // wxUSE_STDPATHS