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