From a3559d56c8c3f7eed5ae1f4e35f00d5f0ff08931 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Thu, 20 Apr 2017 14:44:52 -0500 Subject: [PATCH] Check if file/folder exists before remove --- src/siadrive_api/filepath.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/siadrive_api/filepath.cpp b/src/siadrive_api/filepath.cpp index 17a96ce..4e84267 100644 --- a/src/siadrive_api/filepath.cpp +++ b/src/siadrive_api/filepath.cpp @@ -144,7 +144,7 @@ bool FilePath::CreateDirectory() const bool FilePath::RemoveDirectory() const { #ifdef _WIN32 - return ::RemoveDirectory(&_path[0]) ? true : false; + return !IsDirectory() || ::RemoveDirectory(&_path[0]) ? true : false; #else a #endif @@ -153,7 +153,7 @@ bool FilePath::RemoveDirectory() const bool FilePath::DeleteFile() const { #ifdef _WIN32 - return ::DeleteFile(&_path[0]) ? true : false; + return !IsFile() || ::DeleteFile(&_path[0]) ? true : false; #else a #endif