From 71f83bfff7408330976c9b36bbd820b45ca3241e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 21 Jan 2025 11:57:44 -0400 Subject: [PATCH] rename OsString to OsPath --- Utility/Directory.hs | 14 +++++++------- Utility/{OsString.hs => OsPath.hs} | 23 ++++++++++++----------- git-annex.cabal | 10 +++++----- stack.yaml | 2 +- 4 files changed, 25 insertions(+), 24 deletions(-) rename Utility/{OsString.hs => OsPath.hs} (54%) diff --git a/Utility/Directory.hs b/Utility/Directory.hs index 70b8f60aa5..91a2a1a07b 100644 --- a/Utility/Directory.hs +++ b/Utility/Directory.hs @@ -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/OsString.hs b/Utility/OsPath.hs similarity index 54% rename from Utility/OsString.hs rename to Utility/OsPath.hs index 8f06c6d057..b53a141f3b 100644 --- a/Utility/OsString.hs +++ b/Utility/OsPath.hs @@ -1,4 +1,4 @@ -{- OsString utilities +{- OsPath utilities - - Copyright 2025 Joey Hess - @@ -9,30 +9,31 @@ {-# LANGUAGE PackageImports #-} {-# OPTIONS_GHC -fno-warn-tabs #-} -module Utility.OsString where +module Utility.OsPath where -#ifdef WITH_OSSTRING +#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 OsString will fail. -} -toOsString :: RawFilePath -> OsString + - already or uses of the OsPath will fail. -} +toOsPath :: RawFilePath -> OsPath #if defined(mingw32_HOST_OS) -toOsString = OsString . WindowsString . S.toShort +toOsPath = OsString . WindowsString . S.toShort #else -toOsString = OsString . PosixString . S.toShort +toOsPath = OsString . PosixString . S.toShort #endif -fromOsString :: OsString -> RawFilePath +fromOsPath :: OsPath -> RawFilePath #if defined(mingw32_HOST_OS) -fromOsString = S.fromShort . getWindowsString . getOsString +fromOsPath = S.fromShort . getWindowsString . getOsString #else -fromOsString = S.fromShort . getPosixString . getOsString +fromOsPath = S.fromShort . getPosixString . getOsString #endif -#endif /* WITH_OSSTRING */ +#endif /* WITH_OSPATH */ diff --git a/git-annex.cabal b/git-annex.cabal index d5322b028f..0ece7af41c 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -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 diff --git a/stack.yaml b/stack.yaml index db11c17b90..5ff6f33d09 100644 --- a/stack.yaml +++ b/stack.yaml @@ -11,7 +11,7 @@ flags: benchmark: true crypton: true servant: true - osstring: true + ospath: true packages: - '.' resolver: nightly-2025-01-20