summaryrefslogtreecommitdiff
path: root/splash
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2021-11-19 01:31:06 +0100
committerAlbert Astals Cid <tsdgeos@yahoo.es>2021-12-01 17:51:37 +0000
commite2ec957c0174a36396c3e8c194f44a1f300a950f (patch)
tree5e976e624f29f116e42e8800b5f63b2595c555aa /splash
parent4b6d5121830cee30278fe3c7c84685e3805eb14b (diff)
Use std::filesystem::remove instead of unlink
MSVC is all annoying about unlink() being the wrong name, so use C++17!
Diffstat (limited to 'splash')
-rw-r--r--splash/SplashFontFile.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/splash/SplashFontFile.cc b/splash/SplashFontFile.cc
index d1c2ed0e..c0efd422 100644
--- a/splash/SplashFontFile.cc
+++ b/splash/SplashFontFile.cc
@@ -12,7 +12,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
-// Copyright (C) 2008 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2008, 2021 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2019 Christian Persch <chpe@src.gnome.org>
//
// To see a description of the changes please see the Changelog file that
@@ -23,7 +23,10 @@
#include <config.h>
#include <cstdio>
-#ifdef HAVE_UNISTD_H
+// TODO remove here and below once we depend on a new enough gcc in our CI
+#if __has_include(<filesystem>)
+# include <filesystem>
+#else
# include <unistd.h>
#endif
#include "goo/gmem.h"
@@ -77,8 +80,15 @@ SplashFontSrc::~SplashFontSrc()
{
if (deleteSrc) {
if (isFile) {
- if (fileName)
+ if (fileName) {
+#if __has_include(<filesystem>)
+ // We don't care about any error, but we don't want it to throw
+ std::error_code error_code;
+ std::filesystem::remove(fileName->c_str(), error_code);
+#else
unlink(fileName->c_str());
+#endif
+ }
} else {
if (buf)
gfree(buf);