module Path.Utils (
(</$>)
, changeDir
, splitPath
, toFilePathText
) where
import Control.Monad.Catch
import qualified Data.Text as T
import Data.Text (Text)
import Data.List.Split
import Path
(</$>) :: Functor f => Path b Dir -> f (Path Rel t) -> f (Path b t)
(</$>) d = fmap (d </>)
changeDir :: MonadThrow m => Path b Dir -> Path b' Dir -> Path b t -> m (Path b' t)
changeDir src dst fp = (dst </>) <$> stripProperPrefix src fp
splitPath :: Path Rel t -> [Text]
splitPath = fmap T.pack . splitOn "/" . toFilePath
toFilePathText :: Path b t -> Text
toFilePathText = T.pack . toFilePath