Implement wxFSVolume for macOS

Implement with NSFileManager and NSURL to provide basic functionality
like on MSW. Icons are not implemented for macOS.
This commit is contained in:
Tobias Taschner 2021-11-17 15:40:40 +01:00 committed by Vadim Zeitlin
parent 83886bf18f
commit bbca67df67
9 changed files with 213 additions and 59 deletions

View File

@ -957,6 +957,7 @@ ALL_BASE_SOURCES = \
src/common/utilscmn.cpp \ src/common/utilscmn.cpp \
src/osx/cocoa/power.mm \ src/osx/cocoa/power.mm \
src/osx/cocoa/utils.mm \ src/osx/cocoa/utils.mm \
src/osx/volume.mm \
src/msw/main.cpp \ src/msw/main.cpp \
src/msw/volume.cpp \ src/msw/volume.cpp \
src/common/fs_inet.cpp \ src/common/fs_inet.cpp \
@ -4345,9 +4346,10 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS = \
monodll_msw_uilocale.o monodll_msw_uilocale.o
@COND_PLATFORM_WIN32_1@__BASE_PLATFORM_SRC_OBJECTS = $(COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS) @COND_PLATFORM_WIN32_1@__BASE_PLATFORM_SRC_OBJECTS = $(COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS)
@COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS \ @COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS \
@COND_PLATFORM_WIN32_1@ = monodll_msw_main.o monodll_volume.o @COND_PLATFORM_WIN32_1@ = monodll_msw_main.o monodll_msw_volume.o
@COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS \ @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS \
@COND_TOOLKIT_OSX_COCOA@ = monodll_cocoa_power.o monodll_cocoa_utils.o @COND_TOOLKIT_OSX_COCOA@ = monodll_cocoa_power.o monodll_cocoa_utils.o \
@COND_TOOLKIT_OSX_COCOA@ monodll_osx_volume.o
COND_PLATFORM_MACOSX_1___NET_PLATFORM_SRC_OBJECTS = \ COND_PLATFORM_MACOSX_1___NET_PLATFORM_SRC_OBJECTS = \
monodll_socketiohandler.o \ monodll_socketiohandler.o \
monodll_sockunix.o \ monodll_sockunix.o \
@ -6348,9 +6350,10 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_1 = \
monolib_msw_uilocale.o monolib_msw_uilocale.o
@COND_PLATFORM_WIN32_1@__BASE_PLATFORM_SRC_OBJECTS_1 = $(COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_1) @COND_PLATFORM_WIN32_1@__BASE_PLATFORM_SRC_OBJECTS_1 = $(COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_1)
@COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS_1 \ @COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS_1 \
@COND_PLATFORM_WIN32_1@ = monolib_msw_main.o monolib_volume.o @COND_PLATFORM_WIN32_1@ = monolib_msw_main.o monolib_msw_volume.o
@COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_1 \ @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_1 \
@COND_TOOLKIT_OSX_COCOA@ = monolib_cocoa_power.o monolib_cocoa_utils.o @COND_TOOLKIT_OSX_COCOA@ = monolib_cocoa_power.o monolib_cocoa_utils.o \
@COND_TOOLKIT_OSX_COCOA@ monolib_osx_volume.o
COND_PLATFORM_MACOSX_1___NET_PLATFORM_SRC_OBJECTS_1 = \ COND_PLATFORM_MACOSX_1___NET_PLATFORM_SRC_OBJECTS_1 = \
monolib_socketiohandler.o \ monolib_socketiohandler.o \
monolib_sockunix.o \ monolib_sockunix.o \
@ -8403,9 +8406,10 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_2 = \
basedll_msw_uilocale.o basedll_msw_uilocale.o
@COND_PLATFORM_WIN32_1@__BASE_PLATFORM_SRC_OBJECTS_2 = $(COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_2) @COND_PLATFORM_WIN32_1@__BASE_PLATFORM_SRC_OBJECTS_2 = $(COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_2)
@COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS_2 \ @COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS_2 \
@COND_PLATFORM_WIN32_1@ = basedll_main.o basedll_volume.o @COND_PLATFORM_WIN32_1@ = basedll_main.o basedll_msw_volume.o
@COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_2 \ @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_2 \
@COND_TOOLKIT_OSX_COCOA@ = basedll_cocoa_power.o basedll_cocoa_utils.o @COND_TOOLKIT_OSX_COCOA@ = basedll_cocoa_power.o basedll_cocoa_utils.o \
@COND_TOOLKIT_OSX_COCOA@ basedll_osx_volume.o
COND_MONOLITHIC_0_SHARED_0___baselib___depname = \ COND_MONOLITHIC_0_SHARED_0___baselib___depname = \
$(LIBDIRNAME)/$(LIBPREFIX)wx_base$(WXBASEPORT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)$(LIBEXT) $(LIBDIRNAME)/$(LIBPREFIX)wx_base$(WXBASEPORT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)$(LIBEXT)
@COND_MONOLITHIC_0_SHARED_0@__baselib___depname = $(COND_MONOLITHIC_0_SHARED_0___baselib___depname) @COND_MONOLITHIC_0_SHARED_0@__baselib___depname = $(COND_MONOLITHIC_0_SHARED_0___baselib___depname)
@ -8489,9 +8493,10 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_3 = \
baselib_msw_uilocale.o baselib_msw_uilocale.o
@COND_PLATFORM_WIN32_1@__BASE_PLATFORM_SRC_OBJECTS_3 = $(COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_3) @COND_PLATFORM_WIN32_1@__BASE_PLATFORM_SRC_OBJECTS_3 = $(COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_3)
@COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS_3 \ @COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS_3 \
@COND_PLATFORM_WIN32_1@ = baselib_main.o baselib_volume.o @COND_PLATFORM_WIN32_1@ = baselib_main.o baselib_msw_volume.o
@COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_3 \ @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_3 \
@COND_TOOLKIT_OSX_COCOA@ = baselib_cocoa_power.o baselib_cocoa_utils.o @COND_TOOLKIT_OSX_COCOA@ = baselib_cocoa_power.o baselib_cocoa_utils.o \
@COND_TOOLKIT_OSX_COCOA@ baselib_osx_volume.o
@COND_SHARED_1@____wxbase_namedll_DEP = $(__basedll___depname) @COND_SHARED_1@____wxbase_namedll_DEP = $(__basedll___depname)
@COND_SHARED_0@____wxbase_namelib_DEP = $(__baselib___depname) @COND_SHARED_0@____wxbase_namelib_DEP = $(__baselib___depname)
COND_MONOLITHIC_0_SHARED_1___netdll___depname = \ COND_MONOLITHIC_0_SHARED_1___netdll___depname = \
@ -8662,9 +8667,10 @@ COND_USE_SOVERSOLARIS_1___coredll___so_symlinks_uninst_cmd = rm -f \
@COND_USE_SOVERSOLARIS_1@__coredll___so_symlinks_uninst_cmd = $(COND_USE_SOVERSOLARIS_1___coredll___so_symlinks_uninst_cmd) @COND_USE_SOVERSOLARIS_1@__coredll___so_symlinks_uninst_cmd = $(COND_USE_SOVERSOLARIS_1___coredll___so_symlinks_uninst_cmd)
@COND_PLATFORM_WIN32_1@__coredll___win32rc = coredll_version_rc.o @COND_PLATFORM_WIN32_1@__coredll___win32rc = coredll_version_rc.o
@COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS_4 \ @COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS_4 \
@COND_PLATFORM_WIN32_1@ = coredll_msw_main.o coredll_volume.o @COND_PLATFORM_WIN32_1@ = coredll_msw_main.o coredll_msw_volume.o
@COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_4 \ @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_4 \
@COND_TOOLKIT_OSX_COCOA@ = coredll_power.o coredll_cocoa_utils.o @COND_TOOLKIT_OSX_COCOA@ = coredll_power.o coredll_cocoa_utils.o \
@COND_TOOLKIT_OSX_COCOA@ coredll_osx_volume.o
COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_2 = \ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_2 = \
$(__LOWLEVEL_SRC_OBJECTS_4) \ $(__LOWLEVEL_SRC_OBJECTS_4) \
$(__PLATFORM_SRC_OBJECTS_8) \ $(__PLATFORM_SRC_OBJECTS_8) \
@ -10393,9 +10399,10 @@ COND_MONOLITHIC_0_SHARED_0_USE_GUI_1___corelib___depname = \
@COND_USE_PCH_1@_____pch_wxprec_corelib_wx_wxprec_h_gch___depname \ @COND_USE_PCH_1@_____pch_wxprec_corelib_wx_wxprec_h_gch___depname \
@COND_USE_PCH_1@ = ./.pch/wxprec_corelib/wx/wxprec.h.gch @COND_USE_PCH_1@ = ./.pch/wxprec_corelib/wx/wxprec.h.gch
@COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS_5 \ @COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS_5 \
@COND_PLATFORM_WIN32_1@ = corelib_msw_main.o corelib_volume.o @COND_PLATFORM_WIN32_1@ = corelib_msw_main.o corelib_msw_volume.o
@COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_5 \ @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_5 \
@COND_TOOLKIT_OSX_COCOA@ = corelib_power.o corelib_cocoa_utils.o @COND_TOOLKIT_OSX_COCOA@ = corelib_power.o corelib_cocoa_utils.o \
@COND_TOOLKIT_OSX_COCOA@ corelib_osx_volume.o
COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_3 = \ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_3 = \
$(__LOWLEVEL_SRC_OBJECTS_6) \ $(__LOWLEVEL_SRC_OBJECTS_6) \
$(__PLATFORM_SRC_OBJECTS_9) \ $(__PLATFORM_SRC_OBJECTS_9) \
@ -16178,7 +16185,7 @@ monodll_utilscmn.o: $(srcdir)/src/common/utilscmn.cpp $(MONODLL_ODEP)
monodll_msw_main.o: $(srcdir)/src/msw/main.cpp $(MONODLL_ODEP) monodll_msw_main.o: $(srcdir)/src/msw/main.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/main.cpp $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/main.cpp
monodll_volume.o: $(srcdir)/src/msw/volume.cpp $(MONODLL_ODEP) monodll_msw_volume.o: $(srcdir)/src/msw/volume.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/volume.cpp $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/volume.cpp
monodll_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(MONODLL_ODEP) monodll_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(MONODLL_ODEP)
@ -16187,6 +16194,9 @@ monodll_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(MONODLL_ODEP)
monodll_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(MONODLL_ODEP) monodll_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm
monodll_osx_volume.o: $(srcdir)/src/osx/volume.mm $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/volume.mm
monodll_fs_inet.o: $(srcdir)/src/common/fs_inet.cpp $(MONODLL_ODEP) monodll_fs_inet.o: $(srcdir)/src/common/fs_inet.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/fs_inet.cpp $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/fs_inet.cpp
@ -21485,7 +21495,7 @@ monolib_utilscmn.o: $(srcdir)/src/common/utilscmn.cpp $(MONOLIB_ODEP)
monolib_msw_main.o: $(srcdir)/src/msw/main.cpp $(MONOLIB_ODEP) monolib_msw_main.o: $(srcdir)/src/msw/main.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/main.cpp $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/main.cpp
monolib_volume.o: $(srcdir)/src/msw/volume.cpp $(MONOLIB_ODEP) monolib_msw_volume.o: $(srcdir)/src/msw/volume.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/volume.cpp $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/volume.cpp
monolib_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(MONOLIB_ODEP) monolib_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(MONOLIB_ODEP)
@ -21494,6 +21504,9 @@ monolib_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(MONOLIB_ODEP)
monolib_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(MONOLIB_ODEP) monolib_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm
monolib_osx_volume.o: $(srcdir)/src/osx/volume.mm $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/volume.mm
monolib_fs_inet.o: $(srcdir)/src/common/fs_inet.cpp $(MONOLIB_ODEP) monolib_fs_inet.o: $(srcdir)/src/common/fs_inet.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/fs_inet.cpp $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/fs_inet.cpp
@ -26792,7 +26805,7 @@ basedll_utilscmn.o: $(srcdir)/src/common/utilscmn.cpp $(BASEDLL_ODEP)
basedll_main.o: $(srcdir)/src/msw/main.cpp $(BASEDLL_ODEP) basedll_main.o: $(srcdir)/src/msw/main.cpp $(BASEDLL_ODEP)
$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/msw/main.cpp $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/msw/main.cpp
basedll_volume.o: $(srcdir)/src/msw/volume.cpp $(BASEDLL_ODEP) basedll_msw_volume.o: $(srcdir)/src/msw/volume.cpp $(BASEDLL_ODEP)
$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/msw/volume.cpp $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/msw/volume.cpp
basedll_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(BASEDLL_ODEP) basedll_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(BASEDLL_ODEP)
@ -26801,6 +26814,9 @@ basedll_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(BASEDLL_ODEP)
basedll_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(BASEDLL_ODEP) basedll_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(BASEDLL_ODEP)
$(CXXC) -c -o $@ $(BASEDLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm $(CXXC) -c -o $@ $(BASEDLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm
basedll_osx_volume.o: $(srcdir)/src/osx/volume.mm $(BASEDLL_ODEP)
$(CXXC) -c -o $@ $(BASEDLL_OBJCXXFLAGS) $(srcdir)/src/osx/volume.mm
@COND_PLATFORM_UNIX_1@basedll_fdiodispatcher.o: $(srcdir)/src/common/fdiodispatcher.cpp $(BASEDLL_ODEP) @COND_PLATFORM_UNIX_1@basedll_fdiodispatcher.o: $(srcdir)/src/common/fdiodispatcher.cpp $(BASEDLL_ODEP)
@COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/fdiodispatcher.cpp @COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/fdiodispatcher.cpp
@ -27278,7 +27294,7 @@ baselib_utilscmn.o: $(srcdir)/src/common/utilscmn.cpp $(BASELIB_ODEP)
baselib_main.o: $(srcdir)/src/msw/main.cpp $(BASELIB_ODEP) baselib_main.o: $(srcdir)/src/msw/main.cpp $(BASELIB_ODEP)
$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/msw/main.cpp $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/msw/main.cpp
baselib_volume.o: $(srcdir)/src/msw/volume.cpp $(BASELIB_ODEP) baselib_msw_volume.o: $(srcdir)/src/msw/volume.cpp $(BASELIB_ODEP)
$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/msw/volume.cpp $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/msw/volume.cpp
baselib_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(BASELIB_ODEP) baselib_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(BASELIB_ODEP)
@ -27287,6 +27303,9 @@ baselib_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(BASELIB_ODEP)
baselib_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(BASELIB_ODEP) baselib_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(BASELIB_ODEP)
$(CXXC) -c -o $@ $(BASELIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm $(CXXC) -c -o $@ $(BASELIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm
baselib_osx_volume.o: $(srcdir)/src/osx/volume.mm $(BASELIB_ODEP)
$(CXXC) -c -o $@ $(BASELIB_OBJCXXFLAGS) $(srcdir)/src/osx/volume.mm
@COND_PLATFORM_UNIX_1@baselib_fdiodispatcher.o: $(srcdir)/src/common/fdiodispatcher.cpp $(BASELIB_ODEP) @COND_PLATFORM_UNIX_1@baselib_fdiodispatcher.o: $(srcdir)/src/common/fdiodispatcher.cpp $(BASELIB_ODEP)
@COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/fdiodispatcher.cpp @COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/fdiodispatcher.cpp
@ -27524,7 +27543,7 @@ coredll_utilscmn.o: $(srcdir)/src/common/utilscmn.cpp $(COREDLL_ODEP)
coredll_msw_main.o: $(srcdir)/src/msw/main.cpp $(COREDLL_ODEP) coredll_msw_main.o: $(srcdir)/src/msw/main.cpp $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/main.cpp $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/main.cpp
coredll_volume.o: $(srcdir)/src/msw/volume.cpp $(COREDLL_ODEP) coredll_msw_volume.o: $(srcdir)/src/msw/volume.cpp $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/volume.cpp $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/volume.cpp
coredll_power.o: $(srcdir)/src/osx/cocoa/power.mm $(COREDLL_ODEP) coredll_power.o: $(srcdir)/src/osx/cocoa/power.mm $(COREDLL_ODEP)
@ -27533,6 +27552,9 @@ coredll_power.o: $(srcdir)/src/osx/cocoa/power.mm $(COREDLL_ODEP)
coredll_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(COREDLL_ODEP) coredll_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm $(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm
coredll_osx_volume.o: $(srcdir)/src/osx/volume.mm $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/volume.mm
coredll_gtk_eggtrayicon.o: $(srcdir)/src/gtk/eggtrayicon.c $(COREDLL_ODEP) coredll_gtk_eggtrayicon.o: $(srcdir)/src/gtk/eggtrayicon.c $(COREDLL_ODEP)
$(CCC) -c -o $@ $(COREDLL_CFLAGS) $(srcdir)/src/gtk/eggtrayicon.c $(CCC) -c -o $@ $(COREDLL_CFLAGS) $(srcdir)/src/gtk/eggtrayicon.c
@ -31793,7 +31815,7 @@ corelib_utilscmn.o: $(srcdir)/src/common/utilscmn.cpp $(CORELIB_ODEP)
corelib_msw_main.o: $(srcdir)/src/msw/main.cpp $(CORELIB_ODEP) corelib_msw_main.o: $(srcdir)/src/msw/main.cpp $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/main.cpp $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/main.cpp
corelib_volume.o: $(srcdir)/src/msw/volume.cpp $(CORELIB_ODEP) corelib_msw_volume.o: $(srcdir)/src/msw/volume.cpp $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/volume.cpp $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/volume.cpp
corelib_power.o: $(srcdir)/src/osx/cocoa/power.mm $(CORELIB_ODEP) corelib_power.o: $(srcdir)/src/osx/cocoa/power.mm $(CORELIB_ODEP)
@ -31802,6 +31824,9 @@ corelib_power.o: $(srcdir)/src/osx/cocoa/power.mm $(CORELIB_ODEP)
corelib_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(CORELIB_ODEP) corelib_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm $(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm
corelib_osx_volume.o: $(srcdir)/src/osx/volume.mm $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/volume.mm
corelib_gtk_eggtrayicon.o: $(srcdir)/src/gtk/eggtrayicon.c $(CORELIB_ODEP) corelib_gtk_eggtrayicon.o: $(srcdir)/src/gtk/eggtrayicon.c $(CORELIB_ODEP)
$(CCC) -c -o $@ $(CORELIB_CFLAGS) $(srcdir)/src/gtk/eggtrayicon.c $(CCC) -c -o $@ $(CORELIB_CFLAGS) $(srcdir)/src/gtk/eggtrayicon.c

View File

@ -227,6 +227,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<set var="BASE_AND_GUI_OSX_COCOA_SRC" hints="files"> <set var="BASE_AND_GUI_OSX_COCOA_SRC" hints="files">
src/osx/cocoa/power.mm src/osx/cocoa/power.mm
src/osx/cocoa/utils.mm src/osx/cocoa/utils.mm
src/osx/volume.mm
</set> </set>
<!-- Base files used by non-wxMac OS X builds --> <!-- Base files used by non-wxMac OS X builds -->

View File

@ -154,6 +154,7 @@ set(BASE_OSX_SHARED_HDR
set(BASE_AND_GUI_OSX_COCOA_SRC set(BASE_AND_GUI_OSX_COCOA_SRC
src/osx/cocoa/utils.mm src/osx/cocoa/utils.mm
src/osx/cocoa/power.mm src/osx/cocoa/power.mm
src/osx/volume.mm
) )
set(BASE_OSX_NOTWXMAC_SRC set(BASE_OSX_NOTWXMAC_SRC

View File

@ -178,6 +178,7 @@ BASE_OSX_SHARED_HDR =
BASE_AND_GUI_OSX_COCOA_SRC = BASE_AND_GUI_OSX_COCOA_SRC =
src/osx/cocoa/utils.mm src/osx/cocoa/utils.mm
src/osx/cocoa/power.mm src/osx/cocoa/power.mm
src/osx/volume.mm
# files used by non-wxMac OS X builds # files used by non-wxMac OS X builds
BASE_OSX_NOTWXMAC_SRC = BASE_OSX_NOTWXMAC_SRC =

View File

@ -58,7 +58,7 @@ enum wxFSIconType
Unix ports of wxWidgets do not have the concept of volumes and thus do Unix ports of wxWidgets do not have the concept of volumes and thus do
not implement wxFSVolume. not implement wxFSVolume.
@onlyfor{wxmsw} @onlyfor{wxmsw,wxosx}
@library{wxbase} @library{wxbase}
@category{misc} @category{misc}
@ -138,6 +138,8 @@ public:
This function is available only when @c wxUSE_GUI is @c 1. This function is available only when @c wxUSE_GUI is @c 1.
Returns the icon used by the native toolkit for the given file system type. Returns the icon used by the native toolkit for the given file system type.
@onlyfor{wxmsw}
*/ */
wxIcon GetIcon(wxFSIconType type) const; wxIcon GetIcon(wxFSIconType type) const;
}; };

View File

@ -51,10 +51,13 @@
#include "wx/osx/private.h" // includes mac headers #include "wx/osx/private.h" // includes mac headers
#endif #endif
#if defined(__WINDOWS__) || defined(__APPLE__)
#include "wx/volume.h"
#endif
#ifdef __WINDOWS__ #ifdef __WINDOWS__
#include <windows.h> #include <windows.h>
#include "wx/msw/winundef.h" #include "wx/msw/winundef.h"
#include "wx/volume.h"
// MinGW has _getdrive() and _chdrive(), Cygwin doesn't. // MinGW has _getdrive() and _chdrive(), Cygwin doesn't.
#if defined(__GNUWIN32__) && !defined(__CYGWIN__) #if defined(__GNUWIN32__) && !defined(__CYGWIN__)
@ -91,15 +94,11 @@ wxDEFINE_EVENT( wxEVT_DIRCTRL_FILEACTIVATED, wxTreeEvent );
// wxGetAvailableDrives, for WINDOWS, OSX, UNIX (returns "/") // wxGetAvailableDrives, for WINDOWS, OSX, UNIX (returns "/")
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// since the macOS implementation needs objective-C this is dirdlg.mm
#ifdef __WXOSX__
extern size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayInt &icon_ids);
#else
size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayInt &icon_ids) size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayInt &icon_ids)
{ {
#ifdef wxHAS_FILESYSTEM_VOLUMES #if defined(wxHAS_FILESYSTEM_VOLUMES) || defined(__APPLE__)
#if defined(__WIN32__) && wxUSE_FSVOLUME #if (defined(__WIN32__) || defined(__WXOSX__)) && wxUSE_FSVOLUME
// TODO: this code (using wxFSVolumeBase) should be used for all platforms // TODO: this code (using wxFSVolumeBase) should be used for all platforms
// but unfortunately wxFSVolumeBase is not implemented everywhere // but unfortunately wxFSVolumeBase is not implemented everywhere
const wxArrayString as = wxFSVolumeBase::GetVolumes(); const wxArrayString as = wxFSVolumeBase::GetVolumes();
@ -164,7 +163,6 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI
wxASSERT_MSG( (paths.GetCount() == icon_ids.GetCount()), wxT("Wrong number of icons for available drives.")); wxASSERT_MSG( (paths.GetCount() == icon_ids.GetCount()), wxT("Wrong number of icons for available drives."));
return paths.GetCount(); return paths.GetCount();
} }
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxIsDriveAvailable // wxIsDriveAvailable

View File

@ -173,35 +173,4 @@ void wxDirDialog::SetTitle(const wxString &title)
wxDialog::SetTitle(title); wxDialog::SetTitle(title);
} }
size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayInt &icon_ids)
{
NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
NSArray *volumes = [workspace mountedLocalVolumePaths];
NSFileManager *filemanager = [NSFileManager defaultManager];
for (NSString *path in volumes)
{
NSString *description, *type, *name;
BOOL removable, writable, unmountable;
if ( [workspace getFileSystemInfoForPath:path isRemovable:&removable isWritable:&writable
isUnmountable:&unmountable description:&description type:&type] )
{
if ( writable )
icon_ids.Add(wxFileIconsTable::drive);
else
icon_ids.Add(wxFileIconsTable::cdrom);
name = [filemanager displayNameAtPath:path];
paths.Add(wxCFStringRefFromGet(path).AsString());
names.Add(wxCFStringRefFromGet(name).AsString());
}
}
wxASSERT_MSG( (paths.GetCount() == names.GetCount()), wxT("The number of paths and their human readable names should be equal in number."));
wxASSERT_MSG( (paths.GetCount() == icon_ids.GetCount()), wxT("Wrong number of icons for available drives."));
return paths.GetCount();
}
#endif // wxUSE_DIRDLG #endif // wxUSE_DIRDLG

157
src/osx/volume.mm Normal file
View File

@ -0,0 +1,157 @@
///////////////////////////////////////////////////////////////////////////////
// Name: src/osx/volume.cpp
// Purpose: apple implementation of wxFSVolume
// Author: Tobias Taschner
// Created: 2021-11-17
// Copyright: (c) 2021 wxWidgets development team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/wxprec.h"
#if wxUSE_FSVOLUME
#include "wx/volume.h"
#ifndef WX_PRECOMP
#if wxUSE_GUI
#include "wx/icon.h"
#endif
#endif // WX_PRECOMP
#include "wx/arrimpl.cpp"
#include "wx/osx/core/cfref.h"
#include "wx/osx/core/cfstring.h"
#import <Foundation/NSString.h>
#import <Foundation/NSFileManager.h>
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// wxFSVolume
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
wxArrayString wxFSVolumeBase::GetVolumes(int flagsSet, int flagsUnset)
{
auto nativeVolumes = [[NSFileManager defaultManager]
mountedVolumeURLsIncludingResourceValuesForKeys:nil
options:NSVolumeEnumerationSkipHiddenVolumes];
wxArrayString volumePaths;
if ( nativeVolumes == nil )
{
wxFSVolumeBase volume("/");
int flags = volume.GetFlags();
if ((flags & flagsSet) == flagsSet && !(flags & flagsUnset))
volumePaths.push_back(volume.GetName());
}
else
{
for (NSURL* url in nativeVolumes)
{
wxFSVolumeBase volume(url.fileSystemRepresentation);
int flags = volume.GetFlags();
if ((flags & flagsSet) == flagsSet && !(flags & flagsUnset))
volumePaths.push_back(volume.GetName());
}
}
return volumePaths;
}
void wxFSVolumeBase::CancelSearch()
{
}
wxFSVolumeBase::wxFSVolumeBase()
{
m_isOk = false;
}
wxFSVolumeBase::wxFSVolumeBase(const wxString& name)
{
Create(name);
}
bool wxFSVolumeBase::Create(const wxString& name)
{
m_isOk = false;
m_volName = name;
NSURL* url = [NSURL fileURLWithPath:wxCFStringRef(name).AsNSString()];
auto values = [url resourceValuesForKeys:@[NSURLVolumeLocalizedNameKey] error:nil];
if (values)
{
m_isOk = true;
m_dispName = wxCFStringRef::AsString((CFStringRef)[values objectForKey:NSURLVolumeLocalizedNameKey]);
}
return m_isOk;
}
bool wxFSVolumeBase::IsOk() const
{
return m_isOk;
}
wxFSVolumeKind wxFSVolumeBase::GetKind() const
{
NSURL* url = [NSURL fileURLWithPath:wxCFStringRef(GetName()).AsNSString()];
auto values = [url resourceValuesForKeys:@[NSURLVolumeIsLocalKey, NSURLVolumeIsReadOnlyKey] error:nil];
// Assume disk for local volumes
if ([(NSNumber*)[values objectForKey:NSURLVolumeIsLocalKey] boolValue])
{
if ([(NSNumber*)[values objectForKey:NSURLVolumeIsReadOnlyKey] boolValue])
return wxFS_VOL_CDROM;
else
return wxFS_VOL_DISK;
}
else
return wxFS_VOL_NETWORK;
}
int wxFSVolumeBase::GetFlags() const
{
NSURL* url = [NSURL fileURLWithPath:wxCFStringRef(GetName()).AsNSString()];
auto values = [url resourceValuesForKeys:@[NSURLVolumeIsRemovableKey, NSURLVolumeIsLocalKey, NSURLVolumeIsReadOnlyKey] error:nil];
if (values)
{
// mounted status cannot be determined, assume mounted
int flags = wxFS_VOL_MOUNTED;
if ([(NSNumber*)[values objectForKey:NSURLVolumeIsRemovableKey] boolValue])
flags |= wxFS_VOL_REMOVABLE;
if ([(NSNumber*)[values objectForKey:NSURLVolumeIsReadOnlyKey] boolValue])
flags |= wxFS_VOL_READONLY;
if (![(NSNumber*)[values objectForKey:NSURLVolumeIsLocalKey] boolValue])
flags |= wxFS_VOL_REMOTE;
return flags;
}
else
return -1;
}
#if wxUSE_GUI
void wxFSVolume::InitIcons()
{
// no support for icons on apple
}
wxIcon wxFSVolume::GetIcon(wxFSIconType WXUNUSED(type)) const
{
// no support for icons on apple
return wxNullIcon;
}
#endif // wxUSE_GUI
#endif // wxUSE_FSVOLUME

View File

@ -421,7 +421,7 @@ void InteractiveOutputTestCase::TestStandardPaths()
// wxVolume tests // wxVolume tests
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if !defined(__WIN32__) || !wxUSE_FSVOLUME #if (!defined(__WIN32__) && !defined(__APPLE__)) || defined(__WXOSX_IPHONE__) || !wxUSE_FSVOLUME
#undef TEST_VOLUME #undef TEST_VOLUME
#endif #endif