]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/ide/activegrid/util/appdirs.py
1 #----------------------------------------------------------------------------
3 # Purpose: Utilities for retrieving special application dirs
5 # Author: Kevin Ollivier
9 # Copyright: (c) 2004-2005 ActiveGrid, Inc.
10 # License: wxWindows License
11 #----------------------------------------------------------------------------
13 # NOTE: This was made a separate file because it depends upon the
14 # wx.StandardPaths module, and thus, on wxWidgets, unlike other
15 # utils modules. I wanted to ensure this module is never loaded
16 # from the web server, etc.
24 return os
.name
== 'nt'
26 def _generateDocumentsDir():
28 if sys
.platform
== "win32":
29 from win32com
.shell
import shell
, shellcon
30 path
=shell
.SHGetFolderPath(0, shellcon
.CSIDL_PERSONAL
, None, 0)
31 elif sys
.platform
== "darwin":
33 fsspec_disk
, fsspec_desktop
= macfs
.FindFolder( MACFS
.kOnSystemDisk
, MACFS
.kDocumentsFolderType
, 0)
34 path
= macfs
.FSSpec((fsspec_disk
, fsspec_desktop
, '')).as_pathname()
37 path
= os
.path
.expanduser("~")
41 documents_folder
= _generateDocumentsDir()
43 # NOTE: We don't set this at startup because wxStandardPaths needs a running
44 # application object. This makes sure the wxApp will always be created when
46 def getAppDataFolder():
47 # wxStandardPaths requires a running app
48 if wx
.GetApp() and wx
.Platform
!= "__WXGTK__":
49 data_folder
= wx
.StandardPaths
.Get().GetUserDataDir()
50 if not os
.path
.exists(data_folder
):
54 # wxBug: on *nix, it wants to point to ~/.appname, but
55 # so does wxConfig... For now, redirect this to ~/.appbuilder
56 # when this is fixed, we'll migrate settings to the correct place
57 return os
.path
.join(os
.path
.expanduser("~"), ".appbuilder")