]> dgit.raspbian.org Git - git-annex.git/commitdiff
rename OsString to OsPath
authorJoey Hess <joeyh@joeyh.name>
Tue, 21 Jan 2025 15:57:44 +0000 (11:57 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 21 Jan 2025 15:57:44 +0000 (11:57 -0400)
Utility/Directory.hs
Utility/OsPath.hs [new file with mode: 0644]
Utility/OsString.hs [deleted file]
git-annex.cabal
stack.yaml

index 70b8f60aa560d979a9da7cb364ebae455c18d501..91a2a1a07b37d1721388fa86cbdcc5dda030c432 100644 (file)
@@ -25,8 +25,8 @@ import Utility.Monad
 import Utility.FileSystemEncoding
 import qualified Utility.RawFilePath as R
 
-#ifdef WITH_OSSTRING
-import Utility.OsString
+#ifdef WITH_OSPATH
+import Utility.OsPath
 import qualified System.Directory.OsPath as OP
 #else
 import Utility.SystemDirectory
@@ -45,9 +45,9 @@ dirCruft' _ = False
 {- Lists the contents of a directory.
  - Unlike getDirectoryContents, paths are not relative to the directory. -}
 dirContents :: RawFilePath -> IO [RawFilePath]
-#ifdef WITH_OSSTRING
-dirContents d = map (\p -> d P.</> fromOsString p)
-       <$> OP.listDirectory (toOsString d)
+#ifdef WITH_OSPATH
+dirContents d = map (\p -> d P.</> fromOsPath p)
+       <$> OP.listDirectory (toOsPath d)
 #else
 dirContents d = 
        map (\p -> d P.</> toRawFilePath p) 
@@ -102,8 +102,8 @@ dirContentsRecursiveSkipping skipdir followsubdirsymlinks topdir
                                (Just s) 
                                        | isDirectory s -> recurse
                                        | isSymbolicLink s && followsubdirsymlinks ->
-#ifdef WITH_OSSTRING
-                                               ifM (OP.doesDirectoryExist (toOsString entry))
+#ifdef WITH_OSPATH
+                                               ifM (OP.doesDirectoryExist (toOsPath entry))
 #else
                                                ifM (doesDirectoryExist (fromRawFilePath entry))
 #endif
diff --git a/Utility/OsPath.hs b/Utility/OsPath.hs
new file mode 100644 (file)
index 0000000..b53a141
--- /dev/null
@@ -0,0 +1,39 @@
+{- OsPath utilities
+ -
+ - Copyright 2025 Joey Hess <id@joeyh.name>
+ -
+ - License: BSD-2-clause
+ -}
+
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE PackageImports #-}
+{-# OPTIONS_GHC -fno-warn-tabs #-}
+
+module Utility.OsPath where
+
+#ifdef WITH_OSPATH
+
+import Utility.RawFilePath
+
+import System.OsPath
+import "os-string" System.OsString.Internal.Types
+import qualified Data.ByteString.Short as S
+
+{- Unlike System.OsString.fromBytes, on Windows this does not ensure a
+ - valid USC-2LE encoding. The input ByteString must be in a valid encoding
+ - already or uses of the OsPath will fail. -}
+toOsPath :: RawFilePath -> OsPath
+#if defined(mingw32_HOST_OS)
+toOsPath = OsString . WindowsString . S.toShort
+#else
+toOsPath = OsString . PosixString . S.toShort
+#endif
+
+fromOsPath :: OsPath -> RawFilePath
+#if defined(mingw32_HOST_OS)
+fromOsPath = S.fromShort . getWindowsString . getOsString
+#else
+fromOsPath = S.fromShort . getPosixString . getOsString
+#endif
+
+#endif /* WITH_OSPATH */
diff --git a/Utility/OsString.hs b/Utility/OsString.hs
deleted file mode 100644 (file)
index 8f06c6d..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-{- OsString utilities
- -
- - Copyright 2025 Joey Hess <id@joeyh.name>
- -
- - License: BSD-2-clause
- -}
-
-{-# LANGUAGE CPP #-}
-{-# LANGUAGE PackageImports #-}
-{-# OPTIONS_GHC -fno-warn-tabs #-}
-
-module Utility.OsString where
-
-#ifdef WITH_OSSTRING
-
-import Utility.RawFilePath
-
-import "os-string" System.OsString.Internal.Types
-import qualified Data.ByteString.Short as S
-
-{- Unlike System.OsString.fromBytes, on Windows this does not ensure a
- - valid USC-2LE encoding. The input ByteString must be in a valid encoding
- - already or uses of the OsString will fail. -}
-toOsString :: RawFilePath -> OsString
-#if defined(mingw32_HOST_OS)
-toOsString = OsString . WindowsString . S.toShort
-#else
-toOsString = OsString . PosixString . S.toShort
-#endif
-
-fromOsString :: OsString -> RawFilePath
-#if defined(mingw32_HOST_OS)
-fromOsString = S.fromShort . getWindowsString . getOsString
-#else
-fromOsString = S.fromShort . getPosixString . getOsString
-#endif
-
-#endif /* WITH_OSSTRING */
index d5322b028f47098daac9f92991ab09a269287dc5..0ece7af41cc30679d76c53942970e484e09e7e7f 100644 (file)
@@ -175,8 +175,8 @@ Flag Crypton
 Flag Servant
   Description: Use the servant library, enabling using annex+http urls and git-annex p2phttp
 
-Flag OsString
-  Description: Use the os-string library
+Flag OsPath
+  Description: Use the os-string library and related libraries, for faster filename manipulation
 
 Flag Benchmark
   Description: Enable benchmarking
@@ -332,12 +332,12 @@ Executable git-annex
       P2P.Http.Server
       P2P.Http.State
 
-  if flag(OsString)
+  if flag(OsPath)
     Build-Depends:
       os-string (>= 2.0.0),
       directory (>= 1.3.8.3),
       filepath (>= 1.5.2.0)
-    CPP-Options: -DWITH_OSSTRING
+    CPP-Options: -DWITH_OSPATH
 
   if (os(windows))
     Build-Depends:
@@ -1104,7 +1104,7 @@ Executable git-annex
     Utility.OpenFile
     Utility.OptParse
     Utility.OSX
-    Utility.OsString
+    Utility.OsPath
     Utility.PID
     Utility.PartialPrelude
     Utility.Path
index db11c17b90492c3eba6b8b4d994f856cacb6d952..5ff6f33d09af33bff12af2596763ce879bf264be 100644 (file)
@@ -11,7 +11,7 @@ flags:
     benchmark: true
     crypton: true
     servant: true
-    osstring: true
+    ospath: true
 packages:
 - '.'
 resolver: nightly-2025-01-20