]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/volume.cpp
Comment correction.
[wxWidgets.git] / src / palmos / volume.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/volume.cpp
3 // Purpose: wxFSVolume - encapsulates system volume information
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by:
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "fsvolume.h"
22 #endif
23
24 #include "wx/wxprec.h"
25
26 #ifdef __BORLANDC__
27 #pragma hdrstop
28 #endif
29
30 #if wxUSE_FSVOLUME
31
32 #ifndef WX_PRECOMP
33 #if wxUSE_GUI
34 #include "wx/icon.h"
35 #endif
36 #include "wx/intl.h"
37 #endif // WX_PRECOMP
38
39 #include "wx/arrstr.h"
40 #include "wx/volume.h"
41
42 #include <VFSMgr.h>
43 #include <PalmTypesCompatibility.h>
44
45 #if wxUSE_BASE
46
47 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
48 // Globals/Statics
49 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
50 static long s_cancelSearch = FALSE;
51
52 struct FileInfo
53 {
54 FileInfo(unsigned flag=0, wxFSVolumeKind type=wxFS_VOL_OTHER) :
55 m_flags(flag), m_type(type) {}
56
57 FileInfo(const FileInfo& other) { *this = other; }
58 FileInfo& operator=(const FileInfo& other)
59 {
60 m_flags = other.m_flags;
61 m_type = other.m_type;
62 return *this;
63 }
64
65 unsigned m_flags;
66 wxFSVolumeKind m_type;
67 };
68
69 WX_DECLARE_STRING_HASH_MAP(FileInfo, FileInfoMap);
70
71 // Cygwin bug (?) destructor for global s_fileInfo is called twice...
72 static FileInfoMap& GetFileInfoMap()
73 {
74 static FileInfoMap s_fileInfo(25);
75
76 return s_fileInfo;
77 }
78 #define s_fileInfo (GetFileInfoMap())
79
80 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
81 // Local helper functions.
82 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
83
84 //=============================================================================
85 // Function: GetBasicFlags
86 // Purpose: Set basic flags, primarily wxFS_VOL_REMOTE and wxFS_VOL_REMOVABLE.
87 // Notes: - Local and mapped drives are mounted by definition. We have no
88 // way to determine mounted status of network drives, so assume that
89 // all drives are mounted, and let the caller decide otherwise.
90 // - Other flags are 'best guess' from type of drive. The system will
91 // not report the file attributes with any degree of accuracy.
92 //=============================================================================
93 static unsigned GetBasicFlags(const wxChar* filename)
94 {
95 unsigned flags = wxFS_VOL_MOUNTED;
96
97 return flags;
98 } // GetBasicFlags
99
100 //=============================================================================
101 // Function: FilteredAdd
102 // Purpose: Add a file to the list if it meets the filter requirement.
103 // Notes: - See GetBasicFlags for remarks about the Mounted flag.
104 //=============================================================================
105 static bool FilteredAdd(wxArrayString& list, const wxChar* filename,
106 unsigned flagsSet, unsigned flagsUnset)
107 {
108 return false;
109 } // FilteredAdd
110
111 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
112 // wxFSVolume
113 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
114
115 //=============================================================================
116 // Function: GetVolumes
117 // Purpose: Generate and return a list of all volumes (drives) available.
118 // Notes:
119 //=============================================================================
120 wxArrayString wxFSVolumeBase::GetVolumes(int flagsSet, int flagsUnset)
121 {
122 wxArrayString list;
123
124 UInt16 refNum;
125 UInt32 it = vfsIteratorStart;
126
127 while (it != vfsIteratorStop)
128 {
129 status_t err = VFSVolumeEnumerate(&refNum, &it);
130 if (err == errNone)
131 {
132 // manual: "Volume labels can be up to 255 characters long."
133 char label[256];
134 err = VFSVolumeGetLabel(refNum,label,256);
135 if (err == errNone)
136 {
137 list.Add(wxString::FromAscii(label));
138 }
139 }
140
141 if (err != errNone)
142 break;
143 }
144
145 return list;
146 } // GetVolumes
147
148 //=============================================================================
149 // Function: CancelSearch
150 // Purpose: Instruct an active search to stop.
151 // Notes: - This will only sensibly be called by a thread other than the one
152 // performing the search. This is the only thread-safe function
153 // provided by the class.
154 //=============================================================================
155 void wxFSVolumeBase::CancelSearch()
156 {
157 } // CancelSearch
158
159 //=============================================================================
160 // Function: constructor
161 // Purpose: default constructor
162 //=============================================================================
163 wxFSVolumeBase::wxFSVolumeBase()
164 {
165 } // wxVolume
166
167 //=============================================================================
168 // Function: constructor
169 // Purpose: constructor that calls Create
170 //=============================================================================
171 wxFSVolumeBase::wxFSVolumeBase(const wxString& name)
172 {
173 } // wxVolume
174
175 //=============================================================================
176 // Function: Create
177 // Purpose: Finds, logs in, etc. to the request volume.
178 //=============================================================================
179 bool wxFSVolumeBase::Create(const wxString& name)
180 {
181 return false;
182 } // Create
183
184 //=============================================================================
185 // Function: IsOk
186 // Purpose: returns true if the volume is legal.
187 // Notes: For fixed disks, it must exist. For removable disks, it must also
188 // be present. For Network Shares, it must also be logged in, etc.
189 //=============================================================================
190 bool wxFSVolumeBase::IsOk() const
191 {
192 return false;
193 } // IsOk
194
195 //=============================================================================
196 // Function: GetKind
197 // Purpose: Return the type of the volume.
198 //=============================================================================
199 wxFSVolumeKind wxFSVolumeBase::GetKind() const
200 {
201 return wxFS_VOL_OTHER;
202 }
203
204 //=============================================================================
205 // Function: GetFlags
206 // Purpose: Return the caches flags for this volume.
207 // Notes: - Returns -1 if no flags were cached.
208 //=============================================================================
209 int wxFSVolumeBase::GetFlags() const
210 {
211 return -1;
212 } // GetFlags
213
214 #endif // wxUSE_BASE
215
216 // ============================================================================
217 // wxFSVolume
218 // ============================================================================
219
220 #if wxUSE_GUI
221
222 void wxFSVolume::InitIcons()
223 {
224 }
225
226 //=============================================================================
227 // Function: GetIcon
228 // Purpose: return the requested icon.
229 //=============================================================================
230
231 wxIcon wxFSVolume::GetIcon(wxFSIconType type) const
232 {
233 return m_icons[type];
234 } // GetIcon
235
236 #endif // wxUSE_GUI
237
238 #endif // wxUSE_FSVOLUME
239