]>
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"
35 #include "wx/arrstr.h"
36 #include "wx/volume.h"
39 #include <PalmTypesCompatibility.h>
43 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
45 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
46 static long s_cancelSearch
= FALSE
;
50 FileInfo(unsigned flag
=0, wxFSVolumeKind type
=wxFS_VOL_OTHER
) :
51 m_flags(flag
), m_type(type
) {}
53 FileInfo(const FileInfo
& other
) { *this = other
; }
54 FileInfo
& operator=(const FileInfo
& other
)
56 m_flags
= other
.m_flags
;
57 m_type
= other
.m_type
;
62 wxFSVolumeKind m_type
;
65 WX_DECLARE_STRING_HASH_MAP(FileInfo
, FileInfoMap
);
67 // Cygwin bug (?) destructor for global s_fileInfo is called twice...
68 static FileInfoMap
& GetFileInfoMap()
70 static FileInfoMap
s_fileInfo(25);
74 #define s_fileInfo (GetFileInfoMap())
76 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
77 // Local helper functions.
78 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
80 //=============================================================================
81 // Function: GetBasicFlags
82 // Purpose: Set basic flags, primarily wxFS_VOL_REMOTE and wxFS_VOL_REMOVABLE.
83 // Notes: - Local and mapped drives are mounted by definition. We have no
84 // way to determine mounted status of network drives, so assume that
85 // all drives are mounted, and let the caller decide otherwise.
86 // - Other flags are 'best guess' from type of drive. The system will
87 // not report the file attributes with any degree of accuracy.
88 //=============================================================================
89 static unsigned GetBasicFlags(const wxChar
* filename
)
91 unsigned flags
= wxFS_VOL_MOUNTED
;
96 //=============================================================================
97 // Function: FilteredAdd
98 // Purpose: Add a file to the list if it meets the filter requirement.
99 // Notes: - See GetBasicFlags for remarks about the Mounted flag.
100 //=============================================================================
101 static bool FilteredAdd(wxArrayString
& list
, const wxChar
* filename
,
102 unsigned flagsSet
, unsigned flagsUnset
)
107 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
109 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
111 //=============================================================================
112 // Function: GetVolumes
113 // Purpose: Generate and return a list of all volumes (drives) available.
115 //=============================================================================
116 wxArrayString
wxFSVolumeBase::GetVolumes(int flagsSet
, int flagsUnset
)
121 UInt32 it
= vfsIteratorStart
;
123 while (it
!= vfsIteratorStop
)
125 status_t err
= VFSVolumeEnumerate(&refNum
, &it
);
128 // manual: "Volume labels can be up to 255 characters long."
130 err
= VFSVolumeGetLabel(refNum
,label
,256);
133 list
.Add(wxString::FromAscii(label
));
144 //=============================================================================
145 // Function: CancelSearch
146 // Purpose: Instruct an active search to stop.
147 // Notes: - This will only sensibly be called by a thread other than the one
148 // performing the search. This is the only thread-safe function
149 // provided by the class.
150 //=============================================================================
151 void wxFSVolumeBase::CancelSearch()
155 //=============================================================================
156 // Function: constructor
157 // Purpose: default constructor
158 //=============================================================================
159 wxFSVolumeBase::wxFSVolumeBase()
163 //=============================================================================
164 // Function: constructor
165 // Purpose: constructor that calls Create
166 //=============================================================================
167 wxFSVolumeBase::wxFSVolumeBase(const wxString
& name
)
171 //=============================================================================
173 // Purpose: Finds, logs in, etc. to the request volume.
174 //=============================================================================
175 bool wxFSVolumeBase::Create(const wxString
& name
)
180 //=============================================================================
182 // Purpose: returns true if the volume is legal.
183 // Notes: For fixed disks, it must exist. For removable disks, it must also
184 // be present. For Network Shares, it must also be logged in, etc.
185 //=============================================================================
186 bool wxFSVolumeBase::IsOk() const
191 //=============================================================================
193 // Purpose: Return the type of the volume.
194 //=============================================================================
195 wxFSVolumeKind
wxFSVolumeBase::GetKind() const
197 return wxFS_VOL_OTHER
;
200 //=============================================================================
201 // Function: GetFlags
202 // Purpose: Return the caches flags for this volume.
203 // Notes: - Returns -1 if no flags were cached.
204 //=============================================================================
205 int wxFSVolumeBase::GetFlags() const
212 // ============================================================================
214 // ============================================================================
218 void wxFSVolume::InitIcons()
222 //=============================================================================
224 // Purpose: return the requested icon.
225 //=============================================================================
227 wxIcon
wxFSVolume::GetIcon(wxFSIconType type
) const
229 return m_icons
[type
];
234 #endif // wxUSE_FSVOLUME