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