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