]> git.saurik.com Git - wxWidgets.git/blob - src/common/stdpbase.cpp
mac methodname fixed, so all use the same now
[wxWidgets.git] / src / common / stdpbase.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: common/stdpbase.cpp
3 // Purpose: wxStandardPathsBase methods common to all ports
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 #include "wx/apptrait.h"
33
34 #include "wx/filename.h"
35 #include "wx/stdpaths.h"
36
37 // ----------------------------------------------------------------------------
38 // module globals
39 // ----------------------------------------------------------------------------
40
41 static wxStandardPaths gs_stdPaths;
42
43 // ============================================================================
44 // implementation
45 // ============================================================================
46
47 /* static */
48 wxStandardPathsBase& wxStandardPathsBase::Get()
49 {
50 wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
51 wxCHECK_MSG( traits, gs_stdPaths, _T("create wxApp before calling this") );
52
53 return traits->GetStandardPaths();
54 }
55
56 wxStandardPathsBase& wxAppTraitsBase::GetStandardPaths()
57 {
58 return gs_stdPaths;
59 }
60
61 wxStandardPathsBase::~wxStandardPathsBase()
62 {
63 // nothing to do here
64 }
65
66 wxString wxStandardPathsBase::GetLocalDataDir() const
67 {
68 return GetDataDir();
69 }
70
71 wxString wxStandardPathsBase::GetUserLocalDataDir() const
72 {
73 return GetUserDataDir();
74 }
75
76 wxString wxStandardPathsBase::GetDocumentsDir() const
77 {
78 return wxFileName::GetHomeDir();
79 }
80
81 /* static */
82 wxString wxStandardPathsBase::AppendAppName(const wxString& dir)
83 {
84 wxString subdir(dir);
85
86 // empty string indicates that an error has occurred, don't touch it then
87 if ( !subdir.empty() )
88 {
89 const wxString appname = wxTheApp->GetAppName();
90 if ( !appname.empty() )
91 {
92 const wxChar ch = *(subdir.end() - 1);
93 if ( !wxFileName::IsPathSeparator(ch) && ch != _T('.') )
94 subdir += wxFileName::GetPathSeparator();
95
96 subdir += appname;
97 }
98 }
99
100 return subdir;
101 }
102
103 #endif // wxUSE_STDPATHS