X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ffecfa5aeb540b54914739dbb8603edbbd4c00a0..f4bc1aa27cb33f679d7e9c1518a7855bbc1fa471:/src/palmos/volume.cpp diff --git a/src/palmos/volume.cpp b/src/palmos/volume.cpp index df0f89b4a7..ed18fd3840 100644 --- a/src/palmos/volume.cpp +++ b/src/palmos/volume.cpp @@ -1,10 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// // Name: src/palmos/volume.cpp // Purpose: wxFSVolume - encapsulates system volume information -// Author: William Osborne +// Author: William Osborne - minimal working wxPalmOS port // Modified by: // Created: 10/13/04 -// RCS-ID: $Id: +// RCS-ID: $Id$ // Copyright: (c) William Osborne // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -17,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "fsvolume.h" -#endif - #include "wx/wxprec.h" #ifdef __BORLANDC__ @@ -29,38 +25,26 @@ #if wxUSE_FSVOLUME +#include "wx/volume.h" + #ifndef WX_PRECOMP #if wxUSE_GUI #include "wx/icon.h" #endif #include "wx/intl.h" + #include "wx/arrstr.h" + #include "wx/hashmap.h" #endif // WX_PRECOMP -#include "wx/dir.h" -#include "wx/hashmap.h" -#include "wx/dynlib.h" -#include "wx/arrimpl.cpp" - -#include "wx/volume.h" - -#include "wx/palmos/missing.h" +#include +#ifdef __WXPALMOS6__ +#include +#else +#include +#endif #if wxUSE_BASE -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// Dynamic library function defs. -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -static wxDynamicLibrary s_mprLib; - -typedef DWORD (WINAPI* WNetOpenEnumPtr)(DWORD, DWORD, DWORD, LPNETRESOURCE, LPHANDLE); -typedef DWORD (WINAPI* WNetEnumResourcePtr)(HANDLE, LPDWORD, LPVOID, LPDWORD); -typedef DWORD (WINAPI* WNetCloseEnumPtr)(HANDLE); - -static WNetOpenEnumPtr s_pWNetOpenEnum; -static WNetEnumResourcePtr s_pWNetEnumResource; -static WNetCloseEnumPtr s_pWNetCloseEnum; - //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Globals/Statics //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -82,7 +66,9 @@ struct FileInfo unsigned m_flags; wxFSVolumeKind m_type; }; + WX_DECLARE_STRING_HASH_MAP(FileInfo, FileInfoMap); + // Cygwin bug (?) destructor for global s_fileInfo is called twice... static FileInfoMap& GetFileInfoMap() { @@ -117,47 +103,12 @@ static unsigned GetBasicFlags(const wxChar* filename) // Purpose: Add a file to the list if it meets the filter requirement. // Notes: - See GetBasicFlags for remarks about the Mounted flag. //============================================================================= -static bool FilteredAdd(wxArrayString& list, const wxChar* filename, +static bool FilteredAdd(wxArrayString& list, const wxChar* filename, unsigned flagsSet, unsigned flagsUnset) { return false; } // FilteredAdd -//============================================================================= -// Function: BuildListFromNN -// Purpose: Append or remove items from the list -// Notes: - There is no way to find all disconnected NN items, or even to find -// all items while determining which are connected and not. So this -// function will find either all items or connected items. -//============================================================================= -static void BuildListFromNN(wxArrayString& list, NETRESOURCE* pResSrc, - unsigned flagsSet, unsigned flagsUnset) -{ -} // BuildListFromNN - -//============================================================================= -// Function: CompareFcn -// Purpose: Used to sort the NN list alphabetically, case insensitive. -//============================================================================= -static int CompareFcn(wxString* first, wxString* second) -{ - return wxStricmp(first->c_str(), second->c_str()); -} // CompareFcn - -//============================================================================= -// Function: BuildRemoteList -// Purpose: Append Network Neighborhood items to the list. -// Notes: - Mounted gets transalated into Connected. FilteredAdd is told -// to ignore the Mounted flag since we need to handle it in a weird -// way manually. -// - The resulting list is sorted alphabetically. -//============================================================================= -static bool BuildRemoteList(wxArrayString& list, NETRESOURCE* pResSrc, - unsigned flagsSet, unsigned flagsUnset) -{ - return false; -} // BuildRemoteList - //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // wxFSVolume //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -171,6 +122,27 @@ wxArrayString wxFSVolumeBase::GetVolumes(int flagsSet, int flagsUnset) { wxArrayString list; + UInt16 refNum; + UInt32 it = vfsIteratorStart; + + while (it != vfsIteratorStop) + { + status_t err = VFSVolumeEnumerate(&refNum, &it); + if (err == errNone) + { + // manual: "Volume labels can be up to 255 characters long." + char label[256]; + err = VFSVolumeGetLabel(refNum,label,256); + if (err == errNone) + { + list.Add(wxString::FromAscii(label)); + } + } + + if (err != errNone) + break; + } + return list; } // GetVolumes @@ -212,7 +184,7 @@ bool wxFSVolumeBase::Create(const wxString& name) //============================================================================= // Function: IsOk -// Purpose: returns TRUE if the volume is legal. +// Purpose: returns true if the volume is legal. // Notes: For fixed disks, it must exist. For removable disks, it must also // be present. For Network Shares, it must also be logged in, etc. //============================================================================= @@ -265,4 +237,3 @@ wxIcon wxFSVolume::GetIcon(wxFSIconType type) const #endif // wxUSE_GUI #endif // wxUSE_FSVOLUME -