[poppler] splash/SplashFontFile.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Dec 1 17:59:29 UTC 2021


 splash/SplashFontFile.cc |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

New commits:
commit e2ec957c0174a36396c3e8c194f44a1f300a950f
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri Nov 19 01:31:06 2021 +0100

    Use std::filesystem::remove instead of unlink
    
    MSVC is all annoying about unlink() being the wrong name, so use C++17!

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 at suse.de>
-// Copyright (C) 2008 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2008, 2021 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2019 Christian Persch <chpe at 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);


More information about the poppler mailing list