-- | Lifted "System.Directory.OsPath".
module Effectful.FileSystem.OsPath
  ( -- * Effect
    FileSystem

    -- ** Handlers
  , runFileSystem

    -- * Actions on directories
  , createDirectory
  , createDirectoryIfMissing
  , removeDirectory
  , removeDirectoryRecursive
  , removePathForcibly
  , renameDirectory
  , listDirectory
  , getDirectoryContents

    -- ** Current working directory
  , getCurrentDirectory
  , setCurrentDirectory
  , withCurrentDirectory

    -- * Pre-defined directories
  , getHomeDirectory
  , getXdgDirectory
  , getXdgDirectoryList
  , getAppUserDataDirectory
  , getUserDocumentsDirectory
  , getTemporaryDirectory

    -- * Actions on files
  , removeFile
  , renameFile
  , renamePath
  , copyFile
  , copyFileWithMetadata
  , getFileSize
  , canonicalizePath
  , makeAbsolute
  , makeRelativeToCurrentDirectory

    -- * Existence tests
  , doesPathExist
  , doesFileExist
  , doesDirectoryExist
  , findExecutable
  , findExecutables
  , findExecutablesInDirectories
  , findFile
  , findFiles
  , findFileWith
  , findFilesWith

    -- * Symbolic links
  , createFileLink
  , createDirectoryLink
  , removeDirectoryLink
  , pathIsSymbolicLink
  , getSymbolicLinkTarget

    -- * Permissions
  , getPermissions
  , setPermissions
  , copyPermissions

    -- * Timestamps
  , getAccessTime
  , getModificationTime
  , setAccessTime
  , setModificationTime

    -- * Re-exports

    -- ** Pre-defined directories
  , D.XdgDirectory(..)
  , D.XdgDirectoryList(..)

    -- ** Existence tests
  , D.exeExtension

    -- ** Permissions
  , D.Permissions
  , D.emptyPermissions
  , D.readable
  , D.writable
  , D.executable
  , D.searchable
  , D.setOwnerReadable
  , D.setOwnerWritable
  , D.setOwnerExecutable
  , D.setOwnerSearchable
  ) where

import Data.Time (UTCTime)
import System.Directory.OsPath qualified as D
import System.OsPath (OsPath, OsString)

import Effectful
import Effectful.Dispatch.Static
import Effectful.FileSystem.Effect

----------------------------------------
-- Actions on directories

-- | Lifted 'D.createDirectory'.
createDirectory :: FileSystem :> es => OsPath -> Eff es ()
createDirectory :: forall (es :: [Effect]). (FileSystem :> es) => OsPath -> Eff es ()
createDirectory = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO ()
D.createDirectory

-- | Lifted 'D.createDirectoryIfMissing'.
createDirectoryIfMissing :: FileSystem :> es => Bool -> OsPath -> Eff es ()
createDirectoryIfMissing :: forall (es :: [Effect]).
(FileSystem :> es) =>
Bool -> OsPath -> Eff es ()
createDirectoryIfMissing Bool
doCreateParents =
  IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> OsPath -> IO ()
D.createDirectoryIfMissing Bool
doCreateParents

-- | Lifted 'D.removeDirectory'.
removeDirectory :: FileSystem :> es => OsPath -> Eff es ()
removeDirectory :: forall (es :: [Effect]). (FileSystem :> es) => OsPath -> Eff es ()
removeDirectory = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO ()
D.removeDirectory

-- | Lifted 'D.removeDirectoryRecursive'.
removeDirectoryRecursive :: FileSystem :> es => OsPath -> Eff es ()
removeDirectoryRecursive :: forall (es :: [Effect]). (FileSystem :> es) => OsPath -> Eff es ()
removeDirectoryRecursive = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO ()
D.removeDirectoryRecursive

-- | Lifted 'D.removePathForcibly'.
removePathForcibly :: FileSystem :> es => OsPath -> Eff es ()
removePathForcibly :: forall (es :: [Effect]). (FileSystem :> es) => OsPath -> Eff es ()
removePathForcibly = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO ()
D.removePathForcibly

-- | Lifted 'D.renameDirectory'.
renameDirectory :: FileSystem :> es => OsPath -> OsPath -> Eff es ()
renameDirectory :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> OsPath -> Eff es ()
renameDirectory OsPath
old = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> OsPath -> IO ()
D.renameDirectory OsPath
old

-- | Lifted 'D.listDirectory'.
listDirectory :: FileSystem :> es => OsPath -> Eff es [OsPath]
listDirectory :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es [OsPath]
listDirectory = IO [OsPath] -> Eff es [OsPath]
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO [OsPath] -> Eff es [OsPath])
-> (OsPath -> IO [OsPath]) -> OsPath -> Eff es [OsPath]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO [OsPath]
D.listDirectory

-- | Lifted 'D.getDirectoryContents'.
getDirectoryContents :: FileSystem :> es => OsPath -> Eff es [OsPath]
getDirectoryContents :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es [OsPath]
getDirectoryContents = IO [OsPath] -> Eff es [OsPath]
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO [OsPath] -> Eff es [OsPath])
-> (OsPath -> IO [OsPath]) -> OsPath -> Eff es [OsPath]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO [OsPath]
D.getDirectoryContents

----------------------------------------
-- Current working directory

-- | Lifted 'D.getCurrentDirectory'.
getCurrentDirectory :: FileSystem :> es => Eff es OsPath
getCurrentDirectory :: forall (es :: [Effect]). (FileSystem :> es) => Eff es OsPath
getCurrentDirectory = IO OsPath -> Eff es OsPath
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ IO OsPath
D.getCurrentDirectory

-- | Lifted 'D.setCurrentDirectory'.
setCurrentDirectory :: FileSystem :> es => OsPath -> Eff es ()
setCurrentDirectory :: forall (es :: [Effect]). (FileSystem :> es) => OsPath -> Eff es ()
setCurrentDirectory = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO ()
D.setCurrentDirectory

-- | Lifted 'D.withCurrentDirectory'.
withCurrentDirectory :: FileSystem :> es => OsPath -> Eff es a -> Eff es a
withCurrentDirectory :: forall (es :: [Effect]) a.
(FileSystem :> es) =>
OsPath -> Eff es a -> Eff es a
withCurrentDirectory OsPath
path = (IO a -> IO a) -> Eff es a -> Eff es a
forall a b (es :: [Effect]).
HasCallStack =>
(IO a -> IO b) -> Eff es a -> Eff es b
unsafeLiftMapIO (OsPath -> IO a -> IO a
forall a. OsPath -> IO a -> IO a
D.withCurrentDirectory OsPath
path)

----------------------------------------
-- Pre-defined directories

-- | Lifted 'D.getHomeDirectory'.
getHomeDirectory :: FileSystem :> es => Eff es OsPath
getHomeDirectory :: forall (es :: [Effect]). (FileSystem :> es) => Eff es OsPath
getHomeDirectory = IO OsPath -> Eff es OsPath
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ IO OsPath
D.getHomeDirectory

-- | Lifted 'D.getXdgDirectory'.
getXdgDirectory
  :: FileSystem :> es
  => D.XdgDirectory
  -> OsPath
  -> Eff es OsPath
getXdgDirectory :: forall (es :: [Effect]).
(FileSystem :> es) =>
XdgDirectory -> OsPath -> Eff es OsPath
getXdgDirectory XdgDirectory
xdgDir = IO OsPath -> Eff es OsPath
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO OsPath -> Eff es OsPath)
-> (OsPath -> IO OsPath) -> OsPath -> Eff es OsPath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XdgDirectory -> OsPath -> IO OsPath
D.getXdgDirectory XdgDirectory
xdgDir

-- | Lifted 'D.getXdgDirectoryList'.
getXdgDirectoryList
  :: FileSystem :> es
  => D.XdgDirectoryList
  -> Eff es [OsPath]
getXdgDirectoryList :: forall (es :: [Effect]).
(FileSystem :> es) =>
XdgDirectoryList -> Eff es [OsPath]
getXdgDirectoryList = IO [OsPath] -> Eff es [OsPath]
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO [OsPath] -> Eff es [OsPath])
-> (XdgDirectoryList -> IO [OsPath])
-> XdgDirectoryList
-> Eff es [OsPath]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XdgDirectoryList -> IO [OsPath]
D.getXdgDirectoryList

-- | Lifted 'D.getAppUserDataDirectory'.
getAppUserDataDirectory :: FileSystem :> es => OsPath -> Eff es OsPath
getAppUserDataDirectory :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es OsPath
getAppUserDataDirectory = IO OsPath -> Eff es OsPath
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO OsPath -> Eff es OsPath)
-> (OsPath -> IO OsPath) -> OsPath -> Eff es OsPath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO OsPath
D.getAppUserDataDirectory

-- | Lifted 'D.getUserDocumentsDirectory'.
getUserDocumentsDirectory :: FileSystem :> es => Eff es OsPath
getUserDocumentsDirectory :: forall (es :: [Effect]). (FileSystem :> es) => Eff es OsPath
getUserDocumentsDirectory = IO OsPath -> Eff es OsPath
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ IO OsPath
D.getUserDocumentsDirectory

-- | Lifted 'D.getTemporaryDirectory'.
getTemporaryDirectory :: FileSystem :> es => Eff es OsPath
getTemporaryDirectory :: forall (es :: [Effect]). (FileSystem :> es) => Eff es OsPath
getTemporaryDirectory = IO OsPath -> Eff es OsPath
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ IO OsPath
D.getTemporaryDirectory

----------------------------------------
-- Actions on files

-- | Lifted 'D.removeFile'.
removeFile :: FileSystem :> es => OsPath -> Eff es ()
removeFile :: forall (es :: [Effect]). (FileSystem :> es) => OsPath -> Eff es ()
removeFile = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO ()
D.removeFile

-- | Lifted 'D.renameFile'.
renameFile :: FileSystem :> es => OsPath -> OsPath -> Eff es ()
renameFile :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> OsPath -> Eff es ()
renameFile OsPath
old = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> OsPath -> IO ()
D.renameFile OsPath
old

-- | Lifted 'D.renamePath'.
renamePath :: FileSystem :> es => OsPath -> OsPath -> Eff es ()
renamePath :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> OsPath -> Eff es ()
renamePath OsPath
old = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> OsPath -> IO ()
D.renamePath OsPath
old

-- | Lifted 'D.copyFile'.
copyFile :: FileSystem :> es => OsPath -> OsPath -> Eff es ()
copyFile :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> OsPath -> Eff es ()
copyFile OsPath
src = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> OsPath -> IO ()
D.copyFile OsPath
src

-- | Lifted 'D.copyFileWithMetadata'.
copyFileWithMetadata :: FileSystem :> es => OsPath -> OsPath -> Eff es ()
copyFileWithMetadata :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> OsPath -> Eff es ()
copyFileWithMetadata OsPath
src = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> OsPath -> IO ()
D.copyFileWithMetadata OsPath
src

-- | Lifted 'D.getFileSize'.
getFileSize :: FileSystem :> es => OsPath -> Eff es Integer
getFileSize :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es Integer
getFileSize = IO Integer -> Eff es Integer
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO Integer -> Eff es Integer)
-> (OsPath -> IO Integer) -> OsPath -> Eff es Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO Integer
D.getFileSize

-- | Lifted 'D.canonicalizePath'.
canonicalizePath :: FileSystem :> es => OsPath -> Eff es OsPath
canonicalizePath :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es OsPath
canonicalizePath = IO OsPath -> Eff es OsPath
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO OsPath -> Eff es OsPath)
-> (OsPath -> IO OsPath) -> OsPath -> Eff es OsPath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO OsPath
D.canonicalizePath

-- | Lifted 'D.makeAbsolute'.
makeAbsolute :: FileSystem :> es => OsPath -> Eff es OsPath
makeAbsolute :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es OsPath
makeAbsolute = IO OsPath -> Eff es OsPath
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO OsPath -> Eff es OsPath)
-> (OsPath -> IO OsPath) -> OsPath -> Eff es OsPath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO OsPath
D.makeAbsolute

-- | Lifted 'D.makeRelativeToCurrentDirectory'.
makeRelativeToCurrentDirectory
  :: FileSystem :> es
  => OsPath
  -> Eff es OsPath
makeRelativeToCurrentDirectory :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es OsPath
makeRelativeToCurrentDirectory = IO OsPath -> Eff es OsPath
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO OsPath -> Eff es OsPath)
-> (OsPath -> IO OsPath) -> OsPath -> Eff es OsPath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO OsPath
D.makeRelativeToCurrentDirectory

----------------------------------------
-- Existence tests

-- | Lifted 'D.doesPathExist'.
doesPathExist :: FileSystem :> es => OsPath -> Eff es Bool
doesPathExist :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es Bool
doesPathExist = IO Bool -> Eff es Bool
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO Bool -> Eff es Bool)
-> (OsPath -> IO Bool) -> OsPath -> Eff es Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO Bool
D.doesPathExist

-- | Lifted 'D.doesFileExist'.
doesFileExist :: FileSystem :> es => OsPath -> Eff es Bool
doesFileExist :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es Bool
doesFileExist = IO Bool -> Eff es Bool
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO Bool -> Eff es Bool)
-> (OsPath -> IO Bool) -> OsPath -> Eff es Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO Bool
D.doesFileExist

-- | Lifted 'D.doesDirectoryExist'.
doesDirectoryExist :: FileSystem :> es => OsPath -> Eff es Bool
doesDirectoryExist :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es Bool
doesDirectoryExist = IO Bool -> Eff es Bool
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO Bool -> Eff es Bool)
-> (OsPath -> IO Bool) -> OsPath -> Eff es Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO Bool
D.doesDirectoryExist

-- | Lifted 'D.findExecutable'.
findExecutable :: FileSystem :> es => OsString -> Eff es (Maybe OsPath)
findExecutable :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es (Maybe OsPath)
findExecutable = IO (Maybe OsPath) -> Eff es (Maybe OsPath)
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO (Maybe OsPath) -> Eff es (Maybe OsPath))
-> (OsPath -> IO (Maybe OsPath)) -> OsPath -> Eff es (Maybe OsPath)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO (Maybe OsPath)
D.findExecutable

-- | Lifted 'D.findExecutables'.
findExecutables :: FileSystem :> es => OsString -> Eff es [OsPath]
findExecutables :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es [OsPath]
findExecutables = IO [OsPath] -> Eff es [OsPath]
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO [OsPath] -> Eff es [OsPath])
-> (OsPath -> IO [OsPath]) -> OsPath -> Eff es [OsPath]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO [OsPath]
D.findExecutables

-- | Lifted 'D.findExecutablesInDirectories'.
findExecutablesInDirectories
  :: FileSystem :> es
  => [OsPath]
  -> OsString
  -> Eff es [OsPath]
findExecutablesInDirectories :: forall (es :: [Effect]).
(FileSystem :> es) =>
[OsPath] -> OsPath -> Eff es [OsPath]
findExecutablesInDirectories [OsPath]
dirs =
  IO [OsPath] -> Eff es [OsPath]
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO [OsPath] -> Eff es [OsPath])
-> (OsPath -> IO [OsPath]) -> OsPath -> Eff es [OsPath]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [OsPath] -> OsPath -> IO [OsPath]
D.findExecutablesInDirectories [OsPath]
dirs

-- | Lifted 'D.findFile'.
findFile :: FileSystem :> es => [OsPath] -> OsString -> Eff es (Maybe OsPath)
findFile :: forall (es :: [Effect]).
(FileSystem :> es) =>
[OsPath] -> OsPath -> Eff es (Maybe OsPath)
findFile [OsPath]
dirs = IO (Maybe OsPath) -> Eff es (Maybe OsPath)
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO (Maybe OsPath) -> Eff es (Maybe OsPath))
-> (OsPath -> IO (Maybe OsPath)) -> OsPath -> Eff es (Maybe OsPath)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [OsPath] -> OsPath -> IO (Maybe OsPath)
D.findFile [OsPath]
dirs

-- | Lifted 'D.findFiles'.
findFiles :: FileSystem :> es => [OsPath] -> OsString -> Eff es [OsPath]
findFiles :: forall (es :: [Effect]).
(FileSystem :> es) =>
[OsPath] -> OsPath -> Eff es [OsPath]
findFiles [OsPath]
dirs = IO [OsPath] -> Eff es [OsPath]
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO [OsPath] -> Eff es [OsPath])
-> (OsPath -> IO [OsPath]) -> OsPath -> Eff es [OsPath]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [OsPath] -> OsPath -> IO [OsPath]
D.findFiles [OsPath]
dirs

-- | Lifted 'D.findFileWith'.
findFileWith
  :: FileSystem :> es
  => (OsPath -> Eff es Bool)
  -> [OsPath]
  -> OsString
  -> Eff es (Maybe OsPath)
findFileWith :: forall (es :: [Effect]).
(FileSystem :> es) =>
(OsPath -> Eff es Bool)
-> [OsPath] -> OsPath -> Eff es (Maybe OsPath)
findFileWith OsPath -> Eff es Bool
p [OsPath]
dirs OsPath
n = ((forall r. Eff es r -> IO r) -> IO (Maybe OsPath))
-> Eff es (Maybe OsPath)
forall (es :: [Effect]) a.
HasCallStack =>
((forall r. Eff es r -> IO r) -> IO a) -> Eff es a
unsafeSeqUnliftIO (((forall r. Eff es r -> IO r) -> IO (Maybe OsPath))
 -> Eff es (Maybe OsPath))
-> ((forall r. Eff es r -> IO r) -> IO (Maybe OsPath))
-> Eff es (Maybe OsPath)
forall a b. (a -> b) -> a -> b
$ \forall r. Eff es r -> IO r
unlift -> do
  (OsPath -> IO Bool) -> [OsPath] -> OsPath -> IO (Maybe OsPath)
D.findFileWith (Eff es Bool -> IO Bool
forall r. Eff es r -> IO r
unlift (Eff es Bool -> IO Bool)
-> (OsPath -> Eff es Bool) -> OsPath -> IO Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> Eff es Bool
p) [OsPath]
dirs OsPath
n

-- | Lifted 'D.findFilesWith'.
findFilesWith
  :: FileSystem :> es
  => (OsPath -> Eff es Bool)
  -> [OsPath]
  -> OsString
  -> Eff es [OsPath]
findFilesWith :: forall (es :: [Effect]).
(FileSystem :> es) =>
(OsPath -> Eff es Bool) -> [OsPath] -> OsPath -> Eff es [OsPath]
findFilesWith OsPath -> Eff es Bool
p [OsPath]
dirs OsPath
ns = ((forall r. Eff es r -> IO r) -> IO [OsPath]) -> Eff es [OsPath]
forall (es :: [Effect]) a.
HasCallStack =>
((forall r. Eff es r -> IO r) -> IO a) -> Eff es a
unsafeSeqUnliftIO (((forall r. Eff es r -> IO r) -> IO [OsPath]) -> Eff es [OsPath])
-> ((forall r. Eff es r -> IO r) -> IO [OsPath]) -> Eff es [OsPath]
forall a b. (a -> b) -> a -> b
$ \forall r. Eff es r -> IO r
unlift -> do
  (OsPath -> IO Bool) -> [OsPath] -> OsPath -> IO [OsPath]
D.findFilesWith (Eff es Bool -> IO Bool
forall r. Eff es r -> IO r
unlift (Eff es Bool -> IO Bool)
-> (OsPath -> Eff es Bool) -> OsPath -> IO Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> Eff es Bool
p) [OsPath]
dirs OsPath
ns

----------------------------------------
-- Symbolic links

-- | Lifted 'D.createFileLink'.
createFileLink :: FileSystem :> es => OsPath -> OsPath -> Eff es ()
createFileLink :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> OsPath -> Eff es ()
createFileLink OsPath
target = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> OsPath -> IO ()
D.createFileLink OsPath
target

-- | Lifted 'D.createDirectoryLink'.
createDirectoryLink :: FileSystem :> es => OsPath -> OsPath -> Eff es ()
createDirectoryLink :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> OsPath -> Eff es ()
createDirectoryLink OsPath
target = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> OsPath -> IO ()
D.createDirectoryLink OsPath
target

-- | Lifted 'D.removeDirectoryLink'.
removeDirectoryLink :: FileSystem :> es => OsPath -> Eff es ()
removeDirectoryLink :: forall (es :: [Effect]). (FileSystem :> es) => OsPath -> Eff es ()
removeDirectoryLink = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO ()
D.removeDirectoryLink

-- | Lifted 'D.pathIsSymbolicLink'.
pathIsSymbolicLink :: FileSystem :> es => OsPath -> Eff es Bool
pathIsSymbolicLink :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es Bool
pathIsSymbolicLink = IO Bool -> Eff es Bool
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO Bool -> Eff es Bool)
-> (OsPath -> IO Bool) -> OsPath -> Eff es Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO Bool
D.pathIsSymbolicLink

-- | Lifted 'D.getSymbolicLinkTarget'.
getSymbolicLinkTarget :: FileSystem :> es => OsPath -> Eff es OsPath
getSymbolicLinkTarget :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es OsPath
getSymbolicLinkTarget = IO OsPath -> Eff es OsPath
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO OsPath -> Eff es OsPath)
-> (OsPath -> IO OsPath) -> OsPath -> Eff es OsPath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO OsPath
D.getSymbolicLinkTarget

----------------------------------------
-- Permissions

-- | Lifted 'D.getPermissions'.
getPermissions :: FileSystem :> es => OsPath -> Eff es D.Permissions
getPermissions :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es Permissions
getPermissions = IO Permissions -> Eff es Permissions
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO Permissions -> Eff es Permissions)
-> (OsPath -> IO Permissions) -> OsPath -> Eff es Permissions
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO Permissions
D.getPermissions

-- | Lifted 'D.setPermissions'.
setPermissions :: FileSystem :> es => OsPath -> D.Permissions -> Eff es ()
setPermissions :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Permissions -> Eff es ()
setPermissions OsPath
path = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ())
-> (Permissions -> IO ()) -> Permissions -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> Permissions -> IO ()
D.setPermissions OsPath
path

-- | Lifted 'D.copyPermissions'.
copyPermissions :: FileSystem :> es => OsPath -> OsPath -> Eff es ()
copyPermissions :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> OsPath -> Eff es ()
copyPermissions OsPath
src = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (OsPath -> IO ()) -> OsPath -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> OsPath -> IO ()
D.copyPermissions OsPath
src

----------------------------------------
-- Timestamps

-- | Lifted 'D.getAccessTime'.
getAccessTime :: FileSystem :> es => OsPath -> Eff es UTCTime
getAccessTime :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es UTCTime
getAccessTime = IO UTCTime -> Eff es UTCTime
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO UTCTime -> Eff es UTCTime)
-> (OsPath -> IO UTCTime) -> OsPath -> Eff es UTCTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO UTCTime
D.getAccessTime

-- | Lifted 'D.getModificationTime'.
getModificationTime :: FileSystem :> es => OsPath -> Eff es UTCTime
getModificationTime :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> Eff es UTCTime
getModificationTime = IO UTCTime -> Eff es UTCTime
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO UTCTime -> Eff es UTCTime)
-> (OsPath -> IO UTCTime) -> OsPath -> Eff es UTCTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> IO UTCTime
D.getModificationTime

-- | Lifted 'D.setAccessTime'.
setAccessTime :: FileSystem :> es => OsPath -> UTCTime -> Eff es ()
setAccessTime :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> UTCTime -> Eff es ()
setAccessTime OsPath
path = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (UTCTime -> IO ()) -> UTCTime -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> UTCTime -> IO ()
D.setAccessTime OsPath
path

-- | Lifted 'D.setModificationTime'.
setModificationTime :: FileSystem :> es => OsPath -> UTCTime -> Eff es ()
setModificationTime :: forall (es :: [Effect]).
(FileSystem :> es) =>
OsPath -> UTCTime -> Eff es ()
setModificationTime OsPath
path = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (UTCTime -> IO ()) -> UTCTime -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OsPath -> UTCTime -> IO ()
D.setModificationTime OsPath
path