File tree Expand file tree Collapse file tree
core/src/Streamly/Internal/FileSystem Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -718,15 +718,15 @@ splitPath = splitPathUsing True
718718-- /Unimplemented/
719719{-# INLINE splitHead #-}
720720splitHead :: -- (Unbox a, Integral a) =>
721- OS -> Array a -> (Array a , Array a )
721+ OS -> Array a -> (Array a , Maybe ( Array a ) )
722722splitHead _os _arr = undefined
723723
724724-- | Split the last non-empty path component.
725725--
726726-- /Unimplemented/
727727{-# INLINE splitTail #-}
728728splitTail :: -- (Unbox a, Integral a) =>
729- OS -> Array a -> (Array a , Array a )
729+ OS -> Array a -> (Maybe ( Array a ) , Array a )
730730splitTail _os _arr = undefined
731731
732732------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -150,6 +150,9 @@ module Streamly.Internal.FileSystem.OS_PATH
150150 , splitPath_
151151 , splitFile
152152
153+ , splitFirst
154+ , splitLast
155+
153156 , splitExtension
154157 , dropExtension
155158 , addExtension
@@ -886,6 +889,25 @@ splitFile :: OS_PATH -> Maybe (Maybe OS_PATH, OS_PATH)
886889splitFile (OS_PATH a) =
887890 fmap (bimap (fmap OS_PATH ) OS_PATH ) $ Common. splitFile Common. OS_NAME a
888891
892+ -- | Split the path into the first component and rest of the path. Treats the
893+ -- entire root or share name, if present, as the first component.
894+ --
895+ -- /Unimplemented/
896+ splitFirst :: OS_PATH -> (OS_PATH , Maybe OS_PATH )
897+ splitFirst (OS_PATH a) =
898+ bimap OS_PATH (fmap OS_PATH ) $ Common. splitHead Common. OS_NAME a
899+
900+ -- | Split the path into the last component and rest of the path. Treats the
901+ -- entire root or share name, if present, as the first component.
902+ --
903+ -- >>> basename = snd . Path.splitLast -- Posix basename
904+ -- >>> dirname = fst . Path.splitLast -- Posix dirname
905+ --
906+ -- /Unimplemented/
907+ splitLast :: OS_PATH -> (Maybe OS_PATH , OS_PATH )
908+ splitLast (OS_PATH a) =
909+ bimap (fmap OS_PATH ) OS_PATH $ Common. splitTail Common. OS_NAME a
910+
889911#ifndef IS_WINDOWS
890912-- Note: In the cases of "x.y." and "x.y.." we return no extension rather
891913-- than ".y." or ".y.." as extensions. That is they considered to have no
You can’t perform that action at this time.
0 commit comments