]>
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "fsvolume.h"
24 #include "wx/wxprec.h"
39 #include "wx/arrstr.h"
40 #include "wx/volume.h"
43 #include <PalmTypesCompatibility.h>
47 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
49 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
50 static long s_cancelSearch
= FALSE
;
54 FileInfo(unsigned flag
=0, wxFSVolumeKind type
=wxFS_VOL_OTHER
) :
55 m_flags(flag
), m_type(type
) {}
57 FileInfo(const FileInfo
& other
) { *this = other
; }
58 FileInfo
& operator=(const FileInfo
& other
)
60 m_flags
= other
.m_flags
;
61 m_type
= other
.m_type
;
66 wxFSVolumeKind m_type
;
69 WX_DECLARE_STRING_HASH_MAP(FileInfo
, FileInfoMap
);
71 // Cygwin bug (?) destructor for global s_fileInfo is called twice...
72 static FileInfoMap
& GetFileInfoMap()
74 static FileInfoMap
s_fileInfo(25);
78 #define s_fileInfo (GetFileInfoMap())
80 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
81 // Local helper functions.
82 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
84 //=============================================================================
85 // Function: GetBasicFlags
86 // Purpose: Set basic flags, primarily wxFS_VOL_REMOTE and wxFS_VOL_REMOVABLE.
87 // Notes: - Local and mapped drives are mounted by definition. We have no
88 // way to determine mounted status of network drives, so assume that
89 // all drives are mounted, and let the caller decide otherwise.
90 // - Other flags are 'best guess' from type of drive. The system will
91 // not report the file attributes with any degree of accuracy.
92 //=============================================================================
93 static unsigned GetBasicFlags(const wxChar
* filename
)
95 unsigned flags
= wxFS_VOL_MOUNTED
;
100 //=============================================================================
101 // Function: FilteredAdd
102 // Purpose: Add a file to the list if it meets the filter requirement.
103 // Notes: - See GetBasicFlags for remarks about the Mounted flag.
104 //=============================================================================
105 static bool FilteredAdd(wxArrayString
& list
, const wxChar
* filename
,
106 unsigned flagsSet
, unsigned flagsUnset
)
111 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
113 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
115 //=============================================================================
116 // Function: GetVolumes
117 // Purpose: Generate and return a list of all volumes (drives) available.
119 //=============================================================================
120 wxArrayString
wxFSVolumeBase::GetVolumes(int flagsSet
, int flagsUnset
)
125 UInt32 it
= vfsIteratorStart
;
127 while (it
!= vfsIteratorStop
)
129 status_t err
= VFSVolumeEnumerate(&refNum
, &it
);
132 // manual: "Volume labels can be up to 255 characters long."
134 err
= VFSVolumeGetLabel(refNum
,label
,256);
137 list
.Add(wxString::FromAscii(label
));
148 //=============================================================================
149 // Function: CancelSearch
150 // Purpose: Instruct an active search to stop.
151 // Notes: - This will only sensibly be called by a thread other than the one
152 // performing the search. This is the only thread-safe function
153 // provided by the class.
154 //=============================================================================
155 void wxFSVolumeBase::CancelSearch()
159 //=============================================================================
160 // Function: constructor
161 // Purpose: default constructor
162 //=============================================================================
163 wxFSVolumeBase::wxFSVolumeBase()
167 //=============================================================================
168 // Function: constructor
169 // Purpose: constructor that calls Create
170 //=============================================================================
171 wxFSVolumeBase::wxFSVolumeBase(const wxString
& name
)
175 //=============================================================================
177 // Purpose: Finds, logs in, etc. to the request volume.
178 //=============================================================================
179 bool wxFSVolumeBase::Create(const wxString
& name
)
184 //=============================================================================
186 // Purpose: returns true if the volume is legal.
187 // Notes: For fixed disks, it must exist. For removable disks, it must also
188 // be present. For Network Shares, it must also be logged in, etc.
189 //=============================================================================
190 bool wxFSVolumeBase::IsOk() const
195 //=============================================================================
197 // Purpose: Return the type of the volume.
198 //=============================================================================
199 wxFSVolumeKind
wxFSVolumeBase::GetKind() const
201 return wxFS_VOL_OTHER
;
204 //=============================================================================
205 // Function: GetFlags
206 // Purpose: Return the caches flags for this volume.
207 // Notes: - Returns -1 if no flags were cached.
208 //=============================================================================
209 int wxFSVolumeBase::GetFlags() const
216 // ============================================================================
218 // ============================================================================
222 void wxFSVolume::InitIcons()
226 //=============================================================================
228 // Purpose: return the requested icon.
229 //=============================================================================
231 wxIcon
wxFSVolume::GetIcon(wxFSIconType type
) const
233 return m_icons
[type
];
238 #endif // wxUSE_FSVOLUME