From 3e7dcbc18bb763d4044b1782384e1a9718184976 Mon Sep 17 00:00:00 2001
From: Julian Ospald <hasufell@posteo.de>
Date: Mon, 9 Oct 2023 23:30:48 +0800
Subject: [PATCH] Add haveStatx

---
 System/Posix/Files.hsc             | 1 +
 System/Posix/Files/ByteString.hsc  | 1 +
 System/Posix/Files/Common.hsc      | 9 +++++++++
 System/Posix/Files/PosixString.hsc | 1 +
 changelog.md                       | 4 ++++
 unix.cabal                         | 2 +-
 6 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/System/Posix/Files.hsc b/System/Posix/Files.hsc
index 0810dc7..4243bc3 100644
--- a/System/Posix/Files.hsc
+++ b/System/Posix/Files.hsc
@@ -66,6 +66,7 @@ module System.Posix.Files (
     -- * Extended file status
     ExtendedFileStatus(..),
     CAttributes(..),
+    haveStatx,
     -- ** Obtaining extended file status
     getExtendedFileStatus,
     -- ** Flags
diff --git a/System/Posix/Files/ByteString.hsc b/System/Posix/Files/ByteString.hsc
index 25327cc..e9d22e4 100644
--- a/System/Posix/Files/ByteString.hsc
+++ b/System/Posix/Files/ByteString.hsc
@@ -66,6 +66,7 @@ module System.Posix.Files.ByteString (
     -- * Extended file status
     ExtendedFileStatus(..),
     CAttributes(..),
+    haveStatx,
     -- ** Obtaining extended file status
     getExtendedFileStatus,
     -- ** Flags
diff --git a/System/Posix/Files/Common.hsc b/System/Posix/Files/Common.hsc
index 30ac2b2..c0cd6b6 100644
--- a/System/Posix/Files/Common.hsc
+++ b/System/Posix/Files/Common.hsc
@@ -122,6 +122,7 @@ module System.Posix.Files.Common (
     isDirectoryX,
     isSymbolicLinkX,
     isSocketX,
+    haveStatx,
 
     -- * Setting file sizes
     setFdSize,
@@ -1346,3 +1347,11 @@ getExtendedFileStatus_ fdMay str (StatxFlags flags) (StatxMask masks) = do
 getExtendedFileStatus_ _ _ _ _ = ioError (ioeSetLocation unsupportedOperation "getExtendedFileStatus")
 #endif
 
+-- | Whether 'statx' is available on this platform and 'getExtendedFileStatus' and
+-- related functions will work.
+haveStatx :: Bool
+#ifdef HAVE_STATX
+haveStatx = True
+#else
+haveStatx = False
+#endif
diff --git a/System/Posix/Files/PosixString.hsc b/System/Posix/Files/PosixString.hsc
index 1fdc5d8..3466f83 100644
--- a/System/Posix/Files/PosixString.hsc
+++ b/System/Posix/Files/PosixString.hsc
@@ -62,6 +62,7 @@ module System.Posix.Files.PosixString (
     -- * Extended file status
     ExtendedFileStatus(..),
     CAttributes(..),
+    haveStatx,
     -- ** Obtaining extended file status
     getExtendedFileStatus,
     -- ** Flags
diff --git a/changelog.md b/changelog.md
index 3b741bd..5318270 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,9 @@
 # Changelog for [`unix` package](http://hackage.haskell.org/package/unix)
 
+## 2.8.4.0 *??? 2023*
+
+  * add `haveStatx`
+
 ## 2.8.3.0 *Oct 2023*
 
   * add `getExtendedFileStatus` (based on `statx`) style functions
diff --git a/unix.cabal b/unix.cabal
index 8942c17..380b72f 100644
--- a/unix.cabal
+++ b/unix.cabal
@@ -1,6 +1,6 @@
 cabal-version:  1.12
 name:           unix
-version:        2.8.3.0
+version:        2.8.4.0
 -- NOTE: Don't forget to update ./changelog.md
 
 license:        BSD3
-- 
GitLab