@@ -159,19 +159,19 @@ module Streamly.Internal.FileSystem.OS_PATH_TYPE
159159 , isUnrooted
160160
161161 -- * Joining
162- , extendByString
162+ , joinStr
163163 -- , concat
164- , unsafeExtend
164+ , unsafeJoin
165165#ifndef IS_WINDOWS
166- , extendByCString
167- , extendByCString '
166+ , joinCStr
167+ , joinCStr '
168168#endif
169- , extend
170- , extendDir
169+ , join
170+ , joinDir
171171 , unsafeJoinPaths
172172
173173 -- * Splitting
174- -- | Note: you can use 'unsafeExtend ' as a replacement for the joinDrive
174+ -- | Note: you can use 'unsafeJoin ' as a replacement for the joinDrive
175175 -- function in the filepath package.
176176 , splitRoot
177177 , splitPath
@@ -417,9 +417,9 @@ addTrailingSeparator p@(OS_PATH _arr) =
417417#ifdef IS_WINDOWS
418418 if Array. unsafeGetIndexRev 0 _arr == Common. charToWord ' :'
419419 then p
420- else unsafeExtend p sep
420+ else unsafeJoin p sep
421421#else
422- unsafeExtend p sep
422+ unsafeJoin p sep
423423#endif
424424
425425 where
@@ -717,13 +717,13 @@ fromString_ x =
717717 Left e -> throw e
718718 Right v -> v
719719
720- -- | Extend a path by adding a separator followed by the supplied string to it .
720+ -- | Append a separator followed by the supplied string to a path .
721721--
722722-- Throws 'InvalidPath' if the resulting path is not a valid path as per
723723-- 'validatePath'.
724724--
725- extendByString :: OS_PATH_TYPE -> [Char ] -> OS_PATH_TYPE
726- extendByString (OS_PATH a) b =
725+ joinStr :: OS_PATH_TYPE -> [Char ] -> OS_PATH_TYPE
726+ joinStr (OS_PATH a) b =
727727 OS_PATH $
728728 Common. append Common. OS_NAME
729729 (Common. toString Unicode. UNICODE_DECODER ) a (encodeString b)
@@ -891,9 +891,9 @@ isUnrooted :: OS_PATH_TYPE -> Bool
891891isUnrooted = not . isRooted
892892
893893#ifndef IS_WINDOWS
894- -- | Like 'extend ' but does not check if the second path is rooted.
894+ -- | Like 'join ' but does not check if the second path is rooted.
895895--
896- -- >>> f a b = Path.toString $ Path.unsafeExtend (Path.fromString_ a) (Path.fromString_ b)
896+ -- >>> f a b = Path.toString $ Path.unsafeJoin (Path.fromString_ a) (Path.fromString_ b)
897897--
898898-- >>> f "x" "y"
899899-- "x/y"
@@ -904,21 +904,21 @@ isUnrooted = not . isRooted
904904-- >>> f "x/" "/y"
905905-- "x/y"
906906--
907- {-# INLINE unsafeExtend #-}
908- unsafeExtend :: OS_PATH_TYPE -> OS_PATH_TYPE -> OS_PATH_TYPE
909- unsafeExtend (OS_PATH a) (OS_PATH b) =
907+ {-# INLINE unsafeJoin #-}
908+ unsafeJoin :: OS_PATH_TYPE -> OS_PATH_TYPE -> OS_PATH_TYPE
909+ unsafeJoin (OS_PATH a) (OS_PATH b) =
910910 OS_PATH
911911 $ Common. unsafeAppend
912912 Common. OS_NAME (Common. toString Unicode. UNICODE_DECODER ) a b
913913
914914-- If you want to avoid runtime failure use the typesafe
915915-- Streamly.FileSystem.OS_PATH_TYPE.Seg module.
916916
917- -- | Extend a OS_PATH_TYPE by adding a separator followed by another path to
918- -- it. Fails if the second path is a rooted path. Use 'unsafeExtend ' to avoid
919- -- failure if you know it is ok to append the rooted path.
917+ -- | Append a separator followed by another path to a OS_PATH_TYPE. Fails if
918+ -- the second path is a rooted path. Use 'unsafeJoin ' to avoid failure if you
919+ -- know it is ok to append the rooted path.
920920--
921- -- >>> f a b = Path.toString $ Path.extend a b
921+ -- >>> f a b = Path.toString $ Path.join a b
922922--
923923-- >>> f [path|/usr|] [path|bin|]
924924-- "/usr/bin"
@@ -927,23 +927,23 @@ unsafeExtend (OS_PATH a) (OS_PATH b) =
927927-- >>> fails (f [path|/usr|] [path|/bin|])
928928-- True
929929--
930- extend :: OS_PATH_TYPE -> OS_PATH_TYPE -> OS_PATH_TYPE
931- extend (OS_PATH a) (OS_PATH b) =
930+ join :: OS_PATH_TYPE -> OS_PATH_TYPE -> OS_PATH_TYPE
931+ join (OS_PATH a) (OS_PATH b) =
932932 OS_PATH
933933 $ Common. append
934934 Common. OS_NAME (Common. toString Unicode. UNICODE_DECODER ) a b
935935
936- -- | A stricter version of 'extend ' which requires the first path to be a
936+ -- | A stricter version of 'join ' which requires the first path to be a
937937-- directory like path i.e. having a trailing separator.
938938--
939- -- >>> f a b = Path.toString $ Path.extendDir a b
939+ -- >>> f a b = Path.toString $ Path.joinDir a b
940940--
941941-- >>> fails $ f [path|/usr|] [path|bin|]
942942-- True
943943--
944- extendDir ::
944+ joinDir ::
945945 OS_PATH_TYPE -> OS_PATH_TYPE -> OS_PATH_TYPE
946- extendDir
946+ joinDir
947947 (OS_PATH a) (OS_PATH b) =
948948 OS_PATH
949949 $ Common. append'
@@ -954,21 +954,21 @@ extendDir
954954-- XXX add appendCWString for Windows?
955955
956956#ifndef IS_WINDOWS
957- -- | Append a separator and a CString to the Array. This is like 'unsafeExtend '
957+ -- | Append a separator and a CString to the Array. This is like 'unsafeJoin '
958958-- but always inserts a separator between the two paths even if the first path
959959-- has a trailing separator or second path has a leading separator.
960960--
961- extendByCString :: OS_PATH_TYPE -> CString -> IO OS_PATH_TYPE
962- extendByCString (OS_PATH a) str =
961+ joinCStr :: OS_PATH_TYPE -> CString -> IO OS_PATH_TYPE
962+ joinCStr (OS_PATH a) str =
963963 fmap OS_PATH
964964 $ Common. appendCString
965965 Common. OS_NAME a str
966966
967- -- | Like 'appendCString ' but creates a pinned path.
967+ -- | Like 'joinCStr ' but creates a pinned path.
968968--
969- extendByCString ' ::
969+ joinCStr ' ::
970970 OS_PATH_TYPE -> CString -> IO OS_PATH_TYPE
971- extendByCString '
971+ joinCStr '
972972 (OS_PATH a) str =
973973 fmap OS_PATH
974974 $ Common. appendCString'
@@ -998,7 +998,7 @@ unsafeJoinPaths = undefined
998998-- Some filepath package equivalent idioms:
999999--
10001000-- >>> splitDrive = Path.splitRoot
1001- -- >>> joinDrive = Path.unsafeExtend
1001+ -- >>> joinDrive = Path.unsafeJoin
10021002-- >>> takeDrive = fmap fst . Path.splitRoot
10031003-- >>> dropDrive x = Path.splitRoot x >>= snd
10041004-- >>> hasDrive = isJust . Path.splitRoot
@@ -1360,7 +1360,7 @@ replaceExtension (OS_PATH _a) = undefined
13601360-- present.
13611361--
13621362-- >>> takeFileName = fmap snd . Path.splitFile
1363- -- >>> replaceDirectory p x = fmap (flip Path.extend x) (takeFileName p)
1363+ -- >>> replaceDirectory p x = fmap (flip Path.join x) (takeFileName p)
13641364--
13651365-- >>> fmap Path.toString $ Path.takeFileName [path|/home/user/file.txt|]
13661366-- Just "file.txt"
@@ -1394,7 +1394,7 @@ takeFileBase = fmap dropExtension . takeFileName
13941394-- | Returns the parent directory of the given OS_PATH_TYPE, if any.
13951395--
13961396-- >>> takeDirectory x = Path.splitFile x >>= fst
1397- -- >>> replaceFileName p x = fmap (flip Path.extend x) (takeDirectory p)
1397+ -- >>> replaceFileName p x = fmap (flip Path.join x) (takeDirectory p)
13981398--
13991399-- To get an equivalent to takeDirectory from filepath use
14001400-- 'dropTrailingSeparators' on the result.
0 commit comments