]>
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"
38 #include "wx/hashmap.h"
41 #include <PalmTypesCompatibility.h>
45 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
47 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
48 static long s_cancelSearch
= FALSE
;
52 FileInfo(unsigned flag
=0, wxFSVolumeKind type
=wxFS_VOL_OTHER
) :
53 m_flags(flag
), m_type(type
) {}
55 FileInfo(const FileInfo
& other
) { *this = other
; }
56 FileInfo
& operator=(const FileInfo
& other
)
58 m_flags
= other
.m_flags
;
59 m_type
= other
.m_type
;
64 wxFSVolumeKind m_type
;
67 WX_DECLARE_STRING_HASH_MAP(FileInfo
, FileInfoMap
);
69 // Cygwin bug (?) destructor for global s_fileInfo is called twice...
70 static FileInfoMap
& GetFileInfoMap()
72 static FileInfoMap
s_fileInfo(25);
76 #define s_fileInfo (GetFileInfoMap())
78 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
79 // Local helper functions.
80 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
82 //=============================================================================
83 // Function: GetBasicFlags
84 // Purpose: Set basic flags, primarily wxFS_VOL_REMOTE and wxFS_VOL_REMOVABLE.
85 // Notes: - Local and mapped drives are mounted by definition. We have no
86 // way to determine mounted status of network drives, so assume that
87 // all drives are mounted, and let the caller decide otherwise.
88 // - Other flags are 'best guess' from type of drive. The system will
89 // not report the file attributes with any degree of accuracy.
90 //=============================================================================
91 static unsigned GetBasicFlags(const wxChar
* filename
)
93 unsigned flags
= wxFS_VOL_MOUNTED
;
98 //=============================================================================
99 // Function: FilteredAdd
100 // Purpose: Add a file to the list if it meets the filter requirement.
101 // Notes: - See GetBasicFlags for remarks about the Mounted flag.
102 //=============================================================================
103 static bool FilteredAdd(wxArrayString
& list
, const wxChar
* filename
,
104 unsigned flagsSet
, unsigned flagsUnset
)
109 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
111 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
113 //=============================================================================
114 // Function: GetVolumes
115 // Purpose: Generate and return a list of all volumes (drives) available.
117 //=============================================================================
118 wxArrayString
wxFSVolumeBase::GetVolumes(int flagsSet
, int flagsUnset
)
123 UInt32 it
= vfsIteratorStart
;
125 while (it
!= vfsIteratorStop
)
127 status_t err
= VFSVolumeEnumerate(&refNum
, &it
);
130 // manual: "Volume labels can be up to 255 characters long."
132 err
= VFSVolumeGetLabel(refNum
,label
,256);
135 list
.Add(wxString::FromAscii(label
));
146 //=============================================================================
147 // Function: CancelSearch
148 // Purpose: Instruct an active search to stop.
149 // Notes: - This will only sensibly be called by a thread other than the one
150 // performing the search. This is the only thread-safe function
151 // provided by the class.
152 //=============================================================================
153 void wxFSVolumeBase::CancelSearch()
157 //=============================================================================
158 // Function: constructor
159 // Purpose: default constructor
160 //=============================================================================
161 wxFSVolumeBase::wxFSVolumeBase()
165 //=============================================================================
166 // Function: constructor
167 // Purpose: constructor that calls Create
168 //=============================================================================
169 wxFSVolumeBase::wxFSVolumeBase(const wxString
& name
)
173 //=============================================================================
175 // Purpose: Finds, logs in, etc. to the request volume.
176 //=============================================================================
177 bool wxFSVolumeBase::Create(const wxString
& name
)
182 //=============================================================================
184 // Purpose: returns true if the volume is legal.
185 // Notes: For fixed disks, it must exist. For removable disks, it must also
186 // be present. For Network Shares, it must also be logged in, etc.
187 //=============================================================================
188 bool wxFSVolumeBase::IsOk() const
193 //=============================================================================
195 // Purpose: Return the type of the volume.
196 //=============================================================================
197 wxFSVolumeKind
wxFSVolumeBase::GetKind() const
199 return wxFS_VOL_OTHER
;
202 //=============================================================================
203 // Function: GetFlags
204 // Purpose: Return the caches flags for this volume.
205 // Notes: - Returns -1 if no flags were cached.
206 //=============================================================================
207 int wxFSVolumeBase::GetFlags() const
214 // ============================================================================
216 // ============================================================================
220 void wxFSVolume::InitIcons()
224 //=============================================================================
226 // Purpose: return the requested icon.
227 //=============================================================================
229 wxIcon
wxFSVolume::GetIcon(wxFSIconType type
) const
231 return m_icons
[type
];
236 #endif // wxUSE_FSVOLUME