]>
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
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"
46 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
48 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
49 static long s_cancelSearch
= FALSE
;
53 FileInfo(unsigned flag
=0, wxFSVolumeKind type
=wxFS_VOL_OTHER
) :
54 m_flags(flag
), m_type(type
) {}
56 FileInfo(const FileInfo
& other
) { *this = other
; }
57 FileInfo
& operator=(const FileInfo
& other
)
59 m_flags
= other
.m_flags
;
60 m_type
= other
.m_type
;
65 wxFSVolumeKind m_type
;
68 WX_DECLARE_STRING_HASH_MAP(FileInfo
, FileInfoMap
);
70 // Cygwin bug (?) destructor for global s_fileInfo is called twice...
71 static FileInfoMap
& GetFileInfoMap()
73 static FileInfoMap
s_fileInfo(25);
77 #define s_fileInfo (GetFileInfoMap())
79 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
80 // Local helper functions.
81 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
83 //=============================================================================
84 // Function: GetBasicFlags
85 // Purpose: Set basic flags, primarily wxFS_VOL_REMOTE and wxFS_VOL_REMOVABLE.
86 // Notes: - Local and mapped drives are mounted by definition. We have no
87 // way to determine mounted status of network drives, so assume that
88 // all drives are mounted, and let the caller decide otherwise.
89 // - Other flags are 'best guess' from type of drive. The system will
90 // not report the file attributes with any degree of accuracy.
91 //=============================================================================
92 static unsigned GetBasicFlags(const wxChar
* filename
)
94 unsigned flags
= wxFS_VOL_MOUNTED
;
99 //=============================================================================
100 // Function: FilteredAdd
101 // Purpose: Add a file to the list if it meets the filter requirement.
102 // Notes: - See GetBasicFlags for remarks about the Mounted flag.
103 //=============================================================================
104 static bool FilteredAdd(wxArrayString
& list
, const wxChar
* filename
,
105 unsigned flagsSet
, unsigned flagsUnset
)
110 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
112 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
114 //=============================================================================
115 // Function: GetVolumes
116 // Purpose: Generate and return a list of all volumes (drives) available.
118 //=============================================================================
119 wxArrayString
wxFSVolumeBase::GetVolumes(int flagsSet
, int flagsUnset
)
124 UInt32 it
= vfsIteratorStart
;
126 while (it
!= vfsIteratorStop
)
128 status_t err
= VFSVolumeEnumerate(&refNum
, &it
);
131 // manual: "Volume labels can be up to 255 characters long."
133 err
= VFSVolumeGetLabel(refNum
,label
,256);
136 list
.Add(wxString::FromAscii(label
));
147 //=============================================================================
148 // Function: CancelSearch
149 // Purpose: Instruct an active search to stop.
150 // Notes: - This will only sensibly be called by a thread other than the one
151 // performing the search. This is the only thread-safe function
152 // provided by the class.
153 //=============================================================================
154 void wxFSVolumeBase::CancelSearch()
158 //=============================================================================
159 // Function: constructor
160 // Purpose: default constructor
161 //=============================================================================
162 wxFSVolumeBase::wxFSVolumeBase()
166 //=============================================================================
167 // Function: constructor
168 // Purpose: constructor that calls Create
169 //=============================================================================
170 wxFSVolumeBase::wxFSVolumeBase(const wxString
& name
)
174 //=============================================================================
176 // Purpose: Finds, logs in, etc. to the request volume.
177 //=============================================================================
178 bool wxFSVolumeBase::Create(const wxString
& name
)
183 //=============================================================================
185 // Purpose: returns true if the volume is legal.
186 // Notes: For fixed disks, it must exist. For removable disks, it must also
187 // be present. For Network Shares, it must also be logged in, etc.
188 //=============================================================================
189 bool wxFSVolumeBase::IsOk() const
194 //=============================================================================
196 // Purpose: Return the type of the volume.
197 //=============================================================================
198 wxFSVolumeKind
wxFSVolumeBase::GetKind() const
200 return wxFS_VOL_OTHER
;
203 //=============================================================================
204 // Function: GetFlags
205 // Purpose: Return the caches flags for this volume.
206 // Notes: - Returns -1 if no flags were cached.
207 //=============================================================================
208 int wxFSVolumeBase::GetFlags() const
215 // ============================================================================
217 // ============================================================================
221 void wxFSVolume::InitIcons()
225 //=============================================================================
227 // Purpose: return the requested icon.
228 //=============================================================================
230 wxIcon
wxFSVolume::GetIcon(wxFSIconType type
) const
232 return m_icons
[type
];
237 #endif // wxUSE_FSVOLUME