From 33dbc8ccd17cfe3da75fd4cf6f144f1587e01a54 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Tue, 15 Dec 2020 19:28:58 -0500 Subject: [PATCH] Add IsNetworkPath to kiplatform --- libs/kiplatform/CMakeLists.txt | 4 ++++ libs/kiplatform/gtk/environment.cpp | 7 +++++++ libs/kiplatform/include/kiplatform/environment.h | 10 ++++++++++ libs/kiplatform/msw/environment.cpp | 7 +++++++ libs/kiplatform/osx/environment.mm | 7 +++++++ 5 files changed, 35 insertions(+) diff --git a/libs/kiplatform/CMakeLists.txt b/libs/kiplatform/CMakeLists.txt index 371357f0f7..3a19621b1e 100644 --- a/libs/kiplatform/CMakeLists.txt +++ b/libs/kiplatform/CMakeLists.txt @@ -18,6 +18,10 @@ elseif( WIN32 ) msw/environment.cpp msw/ui.cpp ) + + set( PLATFORM_LIBS + "Shlwapi" + ) elseif( UNIX ) set( PLATFORM_SRCS gtk/app.cpp diff --git a/libs/kiplatform/gtk/environment.cpp b/libs/kiplatform/gtk/environment.cpp index e285706192..2ad532d09b 100644 --- a/libs/kiplatform/gtk/environment.cpp +++ b/libs/kiplatform/gtk/environment.cpp @@ -38,3 +38,10 @@ bool KIPLATFORM::ENV::MoveToTrash( const wxString& aPath, wxString& aError ) return retVal; } + + +bool KIPLATFORM::ENV::IsNetworkPath( const wxString& aPath ) +{ + // placeholder, we "nerf" behavior if its a network path so return false by default + return false; +} \ No newline at end of file diff --git a/libs/kiplatform/include/kiplatform/environment.h b/libs/kiplatform/include/kiplatform/environment.h index 3887449d5a..17890ad660 100644 --- a/libs/kiplatform/include/kiplatform/environment.h +++ b/libs/kiplatform/include/kiplatform/environment.h @@ -33,5 +33,15 @@ namespace KIPLATFORM * @return true if the operation succeeds, false if it fails (see the contents of aError) */ bool MoveToTrash( const wxString& aPath, wxString& aError ); + + /** + * Determines if a given path is a network shared file apth + * On Windows for example, any form of path is accepted drive map or UNC + * + * @param aPath is any kind of file path to be tested + * + * @return true if given path is on a network location + */ + bool IsNetworkPath( const wxString& aPath ); } } diff --git a/libs/kiplatform/msw/environment.cpp b/libs/kiplatform/msw/environment.cpp index 821ed67c64..63e8f4560e 100644 --- a/libs/kiplatform/msw/environment.cpp +++ b/libs/kiplatform/msw/environment.cpp @@ -24,6 +24,7 @@ #include #include +#include bool KIPLATFORM::ENV::MoveToTrash( const wxString& aPath, wxString& aError ) { @@ -49,3 +50,9 @@ bool KIPLATFORM::ENV::MoveToTrash( const wxString& aPath, wxString& aError ) return true; } + + +bool KIPLATFORM::ENV::IsNetworkPath( const wxString& aPath ) +{ + return ::PathIsNetworkPathW( aPath.wc_str() ); +} \ No newline at end of file diff --git a/libs/kiplatform/osx/environment.mm b/libs/kiplatform/osx/environment.mm index 440b8b088c..a0604e4d11 100644 --- a/libs/kiplatform/osx/environment.mm +++ b/libs/kiplatform/osx/environment.mm @@ -43,3 +43,10 @@ bool KIPLATFORM::ENV::MoveToTrash( const wxString& aPath, wxString& aError ) return true; } + + +bool KIPLATFORM::ENV::IsNetworkPath( const wxString& aPath ) +{ + // placeholder, we "nerf" behavior if its a network path so return false by default + return false; +} \ No newline at end of file