]>
git.saurik.com Git - wxWidgets.git/blob - 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
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #include "wx/wxprec.h"
28 #include "wx/volume.h"
35 #include "wx/arrstr.h"
36 #include "wx/hashmap.h"
41 #include <PalmTypesCompatibility.h>
43 #include <PalmCompatibility.h>
48 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
50 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
51 static long s_cancelSearch
= FALSE
;
55 FileInfo(unsigned flag
=0, wxFSVolumeKind type
=wxFS_VOL_OTHER
) :
56 m_flags(flag
), m_type(type
) {}
58 FileInfo(const FileInfo
& other
) { *this = other
; }
59 FileInfo
& operator=(const FileInfo
& other
)
61 m_flags
= other
.m_flags
;
62 m_type
= other
.m_type
;
67 wxFSVolumeKind m_type
;
70 WX_DECLARE_STRING_HASH_MAP(FileInfo
, FileInfoMap
);
72 // Cygwin bug (?) destructor for global s_fileInfo is called twice...
73 static FileInfoMap
& GetFileInfoMap()
75 static FileInfoMap
s_fileInfo(25);
79 #define s_fileInfo (GetFileInfoMap())
81 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
82 // Local helper functions.
83 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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 //=============================================================================
94 static unsigned GetBasicFlags(const wxChar
* filename
)
96 unsigned flags
= wxFS_VOL_MOUNTED
;
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 //=============================================================================
106 static bool FilteredAdd(wxArrayString
& list
, const wxChar
* filename
,
107 unsigned flagsSet
, unsigned flagsUnset
)
112 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
114 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
116 //=============================================================================
117 // Function: GetVolumes
118 // Purpose: Generate and return a list of all volumes (drives) available.
120 //=============================================================================
121 wxArrayString
wxFSVolumeBase::GetVolumes(int flagsSet
, int flagsUnset
)
126 UInt32 it
= vfsIteratorStart
;
128 while (it
!= vfsIteratorStop
)
130 status_t err
= VFSVolumeEnumerate(&refNum
, &it
);
133 // manual: "Volume labels can be up to 255 characters long."
135 err
= VFSVolumeGetLabel(refNum
,label
,256);
138 list
.Add(wxString::FromAscii(label
));
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 //=============================================================================
156 void wxFSVolumeBase::CancelSearch()
160 //=============================================================================
161 // Function: constructor
162 // Purpose: default constructor
163 //=============================================================================
164 wxFSVolumeBase::wxFSVolumeBase()
168 //=============================================================================
169 // Function: constructor
170 // Purpose: constructor that calls Create
171 //=============================================================================
172 wxFSVolumeBase::wxFSVolumeBase(const wxString
& name
)
176 //=============================================================================
178 // Purpose: Finds, logs in, etc. to the request volume.
179 //=============================================================================
180 bool wxFSVolumeBase::Create(const wxString
& name
)
185 //=============================================================================
187 // Purpose: returns true if the volume is legal.
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 //=============================================================================
191 bool wxFSVolumeBase::IsOk() const
196 //=============================================================================
198 // Purpose: Return the type of the volume.
199 //=============================================================================
200 wxFSVolumeKind
wxFSVolumeBase::GetKind() const
202 return wxFS_VOL_OTHER
;
205 //=============================================================================
206 // Function: GetFlags
207 // Purpose: Return the caches flags for this volume.
208 // Notes: - Returns -1 if no flags were cached.
209 //=============================================================================
210 int wxFSVolumeBase::GetFlags() const
217 // ============================================================================
219 // ============================================================================
223 void wxFSVolume::InitIcons()
227 //=============================================================================
229 // Purpose: return the requested icon.
230 //=============================================================================
232 wxIcon
wxFSVolume::GetIcon(wxFSIconType type
) const
234 return m_icons
[type
];
239 #endif // wxUSE_FSVOLUME