]>
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" 
  40 #include <PalmTypesCompatibility.h> 
  44 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  46 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  47 static long s_cancelSearch 
= FALSE
; 
  51     FileInfo(unsigned flag
=0, wxFSVolumeKind type
=wxFS_VOL_OTHER
) : 
  52         m_flags(flag
), m_type(type
) {} 
  54     FileInfo(const FileInfo
& other
) { *this = other
; } 
  55     FileInfo
& operator=(const FileInfo
& other
) 
  57         m_flags 
= other
.m_flags
; 
  58         m_type 
= other
.m_type
; 
  63     wxFSVolumeKind m_type
; 
  66 WX_DECLARE_STRING_HASH_MAP(FileInfo
, FileInfoMap
); 
  68 // Cygwin bug (?) destructor for global s_fileInfo is called twice... 
  69 static FileInfoMap
& GetFileInfoMap() 
  71     static FileInfoMap 
s_fileInfo(25); 
  75 #define s_fileInfo (GetFileInfoMap()) 
  77 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  78 // Local helper functions. 
  79 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  81 //============================================================================= 
  82 // Function: GetBasicFlags 
  83 // Purpose: Set basic flags, primarily wxFS_VOL_REMOTE and wxFS_VOL_REMOVABLE. 
  84 // Notes: - Local and mapped drives are mounted by definition.  We have no 
  85 //          way to determine mounted status of network drives, so assume that 
  86 //          all drives are mounted, and let the caller decide otherwise. 
  87 //        - Other flags are 'best guess' from type of drive.  The system will 
  88 //          not report the file attributes with any degree of accuracy. 
  89 //============================================================================= 
  90 static unsigned GetBasicFlags(const wxChar
* filename
) 
  92     unsigned flags 
= wxFS_VOL_MOUNTED
; 
  97 //============================================================================= 
  98 // Function: FilteredAdd 
  99 // Purpose: Add a file to the list if it meets the filter requirement. 
 100 // Notes: - See GetBasicFlags for remarks about the Mounted flag. 
 101 //============================================================================= 
 102 static bool FilteredAdd(wxArrayString
& list
, const wxChar
* filename
, 
 103                         unsigned flagsSet
, unsigned flagsUnset
) 
 108 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
 110 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
 112 //============================================================================= 
 113 // Function: GetVolumes 
 114 // Purpose: Generate and return a list of all volumes (drives) available. 
 116 //============================================================================= 
 117 wxArrayString 
wxFSVolumeBase::GetVolumes(int flagsSet
, int flagsUnset
) 
 122     UInt32 it 
= vfsIteratorStart
; 
 124     while (it 
!= vfsIteratorStop
) 
 126         status_t err 
= VFSVolumeEnumerate(&refNum
, &it
); 
 129             // manual: "Volume labels can be up to 255 characters long." 
 131             err 
= VFSVolumeGetLabel(refNum
,label
,256); 
 134                 list
.Add(wxString::FromAscii(label
)); 
 145 //============================================================================= 
 146 // Function: CancelSearch 
 147 // Purpose: Instruct an active search to stop. 
 148 // Notes: - This will only sensibly be called by a thread other than the one 
 149 //          performing the search.  This is the only thread-safe function 
 150 //          provided by the class. 
 151 //============================================================================= 
 152 void wxFSVolumeBase::CancelSearch() 
 156 //============================================================================= 
 157 // Function: constructor 
 158 // Purpose: default constructor 
 159 //============================================================================= 
 160 wxFSVolumeBase::wxFSVolumeBase() 
 164 //============================================================================= 
 165 // Function: constructor 
 166 // Purpose: constructor that calls Create 
 167 //============================================================================= 
 168 wxFSVolumeBase::wxFSVolumeBase(const wxString
& name
) 
 172 //============================================================================= 
 174 // Purpose: Finds, logs in, etc. to the request volume. 
 175 //============================================================================= 
 176 bool wxFSVolumeBase::Create(const wxString
& name
) 
 181 //============================================================================= 
 183 // Purpose: returns true if the volume is legal. 
 184 // Notes: For fixed disks, it must exist.  For removable disks, it must also 
 185 //        be present.  For Network Shares, it must also be logged in, etc. 
 186 //============================================================================= 
 187 bool wxFSVolumeBase::IsOk() const 
 192 //============================================================================= 
 194 // Purpose: Return the type of the volume. 
 195 //============================================================================= 
 196 wxFSVolumeKind 
wxFSVolumeBase::GetKind() const 
 198     return wxFS_VOL_OTHER
; 
 201 //============================================================================= 
 202 // Function: GetFlags 
 203 // Purpose: Return the caches flags for this volume. 
 204 // Notes: - Returns -1 if no flags were cached. 
 205 //============================================================================= 
 206 int wxFSVolumeBase::GetFlags() const 
 213 // ============================================================================ 
 215 // ============================================================================ 
 219 void wxFSVolume::InitIcons() 
 223 //============================================================================= 
 225 // Purpose: return the requested icon. 
 226 //============================================================================= 
 228 wxIcon 
wxFSVolume::GetIcon(wxFSIconType type
) const 
 230     return m_icons
[type
]; 
 235 #endif // wxUSE_FSVOLUME