2002-02-13 16:01:50 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/volume.h
|
|
|
|
// Purpose: wxFSVolume - encapsulates system volume information
|
|
|
|
// Author: George Policello
|
|
|
|
// Modified by:
|
|
|
|
// Created: 28 Jan 02
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 2002 George Policello
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2002-02-13 16:01:50 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2008-11-22 10:54:33 -05:00
|
|
|
// wxFSVolume represents a volume/drive in a file system
|
2002-02-13 16:01:50 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifndef _WX_FSVOLUME_H_
|
|
|
|
#define _WX_FSVOLUME_H_
|
|
|
|
|
2002-02-23 19:19:01 -05:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_FSVOLUME
|
|
|
|
|
2006-05-28 19:08:31 -04:00
|
|
|
#include "wx/arrstr.h"
|
|
|
|
|
2002-02-13 16:01:50 -05:00
|
|
|
// the volume flags
|
2008-11-22 10:54:33 -05:00
|
|
|
enum wxFSVolumeFlags
|
2002-02-13 16:01:50 -05:00
|
|
|
{
|
|
|
|
// is the volume mounted?
|
|
|
|
wxFS_VOL_MOUNTED = 0x0001,
|
|
|
|
|
|
|
|
// is the volume removable (floppy, CD, ...)?
|
|
|
|
wxFS_VOL_REMOVABLE = 0x0002,
|
|
|
|
|
|
|
|
// read only? (otherwise read write)
|
|
|
|
wxFS_VOL_READONLY = 0x0004,
|
|
|
|
|
|
|
|
// network resources
|
|
|
|
wxFS_VOL_REMOTE = 0x0008
|
|
|
|
};
|
|
|
|
|
|
|
|
// the volume types
|
|
|
|
enum wxFSVolumeKind
|
|
|
|
{
|
|
|
|
wxFS_VOL_FLOPPY,
|
|
|
|
wxFS_VOL_DISK,
|
|
|
|
wxFS_VOL_CDROM,
|
|
|
|
wxFS_VOL_DVDROM,
|
|
|
|
wxFS_VOL_NETWORK,
|
|
|
|
wxFS_VOL_OTHER,
|
|
|
|
wxFS_VOL_MAX
|
|
|
|
};
|
|
|
|
|
2003-07-01 21:59:24 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxFSVolumeBase
|
2002-02-13 16:01:50 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// return the array containing the names of the volumes
|
|
|
|
//
|
|
|
|
// only the volumes with the flags such that
|
|
|
|
// (flags & flagsSet) == flagsSet && !(flags & flagsUnset)
|
|
|
|
// are returned (by default, all mounted ones)
|
|
|
|
static wxArrayString GetVolumes(int flagsSet = wxFS_VOL_MOUNTED,
|
|
|
|
int flagsUnset = 0);
|
|
|
|
|
|
|
|
// stop execution of GetVolumes() called previously (should be called from
|
|
|
|
// another thread, of course)
|
|
|
|
static void CancelSearch();
|
|
|
|
|
|
|
|
// create the volume object with this name (should be one of those returned
|
|
|
|
// by GetVolumes()).
|
2003-06-23 20:56:19 -04:00
|
|
|
wxFSVolumeBase();
|
|
|
|
wxFSVolumeBase(const wxString& name);
|
2002-02-13 16:01:50 -05:00
|
|
|
bool Create(const wxString& name);
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
// ---------
|
|
|
|
|
|
|
|
// is this a valid volume?
|
|
|
|
bool IsOk() const;
|
|
|
|
|
|
|
|
// kind of this volume?
|
|
|
|
wxFSVolumeKind GetKind() const;
|
|
|
|
|
|
|
|
// flags of this volume?
|
|
|
|
int GetFlags() const;
|
|
|
|
|
|
|
|
// can we write to this volume?
|
|
|
|
bool IsWritable() const { return !(GetFlags() & wxFS_VOL_READONLY); }
|
|
|
|
|
|
|
|
// get the name of the volume and the name which should be displayed to the
|
|
|
|
// user
|
|
|
|
wxString GetName() const { return m_volName; }
|
|
|
|
wxString GetDisplayName() const { return m_dispName; }
|
|
|
|
|
|
|
|
// TODO: operatios (Mount(), Unmount(), Eject(), ...)?
|
|
|
|
|
2003-06-23 20:56:19 -04:00
|
|
|
protected:
|
|
|
|
// the internal volume name
|
2002-02-13 16:01:50 -05:00
|
|
|
wxString m_volName;
|
2003-06-23 20:56:19 -04:00
|
|
|
|
|
|
|
// the volume name as it is displayed to the user
|
2002-02-13 16:01:50 -05:00
|
|
|
wxString m_dispName;
|
2003-06-23 20:56:19 -04:00
|
|
|
|
|
|
|
// have we been initialized correctly?
|
|
|
|
bool m_isOk;
|
|
|
|
};
|
|
|
|
|
2002-02-13 16:01:50 -05:00
|
|
|
#if wxUSE_GUI
|
2003-06-23 20:56:19 -04:00
|
|
|
|
|
|
|
#include "wx/icon.h"
|
|
|
|
#include "wx/iconbndl.h" // only for wxIconArray
|
|
|
|
|
|
|
|
enum wxFSIconType
|
|
|
|
{
|
|
|
|
wxFS_VOL_ICO_SMALL = 0,
|
|
|
|
wxFS_VOL_ICO_LARGE,
|
|
|
|
wxFS_VOL_ICO_SEL_SMALL,
|
|
|
|
wxFS_VOL_ICO_SEL_LARGE,
|
|
|
|
wxFS_VOL_ICO_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
// wxFSVolume adds GetIcon() to wxFSVolumeBase
|
2005-12-22 19:59:29 -05:00
|
|
|
class WXDLLIMPEXP_CORE wxFSVolume : public wxFSVolumeBase
|
2003-06-23 20:56:19 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxFSVolume() : wxFSVolumeBase() { InitIcons(); }
|
|
|
|
wxFSVolume(const wxString& name) : wxFSVolumeBase(name) { InitIcons(); }
|
|
|
|
|
|
|
|
wxIcon GetIcon(wxFSIconType type) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void InitIcons();
|
|
|
|
|
|
|
|
// the different icons for this volume (created on demand)
|
2002-02-13 16:01:50 -05:00
|
|
|
wxIconArray m_icons;
|
2003-06-23 20:56:19 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#else // !wxUSE_GUI
|
2002-02-13 16:01:50 -05:00
|
|
|
|
2003-06-23 20:56:19 -04:00
|
|
|
// wxFSVolume is the same thing as wxFSVolume in wxBase
|
2004-01-31 09:49:51 -05:00
|
|
|
typedef wxFSVolumeBase wxFSVolume;
|
2002-02-13 16:01:50 -05:00
|
|
|
|
2003-06-23 20:56:19 -04:00
|
|
|
#endif // wxUSE_GUI/!wxUSE_GUI
|
|
|
|
|
2002-02-23 19:19:01 -05:00
|
|
|
#endif // wxUSE_FSVOLUME
|
|
|
|
|
2002-02-13 16:01:50 -05:00
|
|
|
#endif // _WX_FSVOLUME_H_
|