Add IsDirectory
This commit is contained in:
parent
da7ea65cf5
commit
8aaa056978
|
@ -28,6 +28,7 @@ module DependencyGenerator
|
||||||
, applyTemplate
|
, applyTemplate
|
||||||
, toText
|
, toText
|
||||||
, listDirectory
|
, listDirectory
|
||||||
|
, isDirectory
|
||||||
, readTemplate
|
, readTemplate
|
||||||
, convertImage
|
, convertImage
|
||||||
, saveFile
|
, saveFile
|
||||||
|
@ -214,6 +215,9 @@ toText a = runFunction ToText =<< toToken a
|
||||||
listDirectory :: TokenableTo FilePath a => a -> DepGenM' [FilePath]
|
listDirectory :: TokenableTo FilePath a => a -> DepGenM' [FilePath]
|
||||||
listDirectory a = runFunctionIO ListDirectory =<< toToken a
|
listDirectory a = runFunctionIO ListDirectory =<< toToken a
|
||||||
|
|
||||||
|
isDirectory :: TokenableTo FilePath a => a -> DepGenM' Bool
|
||||||
|
isDirectory a = runFunctionIO IsDirectory =<< toToken a
|
||||||
|
|
||||||
readTemplate :: TokenableTo FilePath a => a -> DepGenM' Template
|
readTemplate :: TokenableTo FilePath a => a -> DepGenM' Template
|
||||||
readTemplate a = runFunctionIO ReadTemplate =<< toToken a
|
readTemplate a = runFunctionIO ReadTemplate =<< toToken a
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,16 @@ import qualified Text.Pandoc as P
|
||||||
import qualified Text.Blaze.Html.Renderer.Text as B
|
import qualified Text.Blaze.Html.Renderer.Text as B
|
||||||
import qualified Codec.Picture as CP
|
import qualified Codec.Picture as CP
|
||||||
import qualified Codec.Picture.STBIR as CPS
|
import qualified Codec.Picture.STBIR as CPS
|
||||||
import System.Directory (listDirectory, createDirectory, copyFile)
|
import System.Directory (listDirectory, doesDirectoryExist, createDirectory, copyFile)
|
||||||
|
|
||||||
evalFunctionIO :: FunctionIO -> Value -> IO Value
|
evalFunctionIO :: FunctionIO -> Value -> IO Value
|
||||||
evalFunctionIO f x = case (f, x) of
|
evalFunctionIO f x = case (f, x) of
|
||||||
(ListDirectory, String s) ->
|
(ListDirectory, String s) ->
|
||||||
(List . map toValue) <$> listDirectory s
|
(List . map toValue) <$> listDirectory s
|
||||||
|
|
||||||
|
(IsDirectory, String s) ->
|
||||||
|
Bool <$> doesDirectoryExist s
|
||||||
|
|
||||||
(ReadTemplate, String s) -> do
|
(ReadTemplate, String s) -> do
|
||||||
t <- T.readFile s
|
t <- T.readFile s
|
||||||
let c = "CONTENT"
|
let c = "CONTENT"
|
||||||
|
|
|
@ -5,6 +5,7 @@ module Types.FunctionIO
|
||||||
import Language.Haskell.TH.Syntax (Lift)
|
import Language.Haskell.TH.Syntax (Lift)
|
||||||
|
|
||||||
data FunctionIO = ListDirectory
|
data FunctionIO = ListDirectory
|
||||||
|
| IsDirectory
|
||||||
| ReadTemplate
|
| ReadTemplate
|
||||||
| ConvertImage
|
| ConvertImage
|
||||||
| SaveFile
|
| SaveFile
|
||||||
|
|
Loading…
Reference in New Issue