summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2016-04-27 18:30:31 -0400
committerjoe <joe@jerkface.net>2016-04-27 18:30:31 -0400
commit42c794b76908869a282dbad771af8163b12b318d (patch)
tree4163103786b3a3b43a1638b5624b7c6634dd163b
parent6260d694a99348bc474b87b3d2184ead70cf3511 (diff)
made cokiki create parent directories for missing config files.
-rw-r--r--cokiki.hs2
-rw-r--r--kiki.cabal1
2 files changed, 3 insertions, 0 deletions
diff --git a/cokiki.hs b/cokiki.hs
index 26748b2..9448aea 100644
--- a/cokiki.hs
+++ b/cokiki.hs
@@ -10,6 +10,7 @@ import qualified Data.ByteString.Lazy.Char8 as L
10import qualified Data.ByteString.Lazy.Char8 as L8 10import qualified Data.ByteString.Lazy.Char8 as L8
11import qualified Kiki 11import qualified Kiki
12import System.Directory 12import System.Directory
13import System.FilePath.Posix (takeDirectory)
13import System.Environment 14import System.Environment
14import System.IO 15import System.IO
15import System.Posix.User 16import System.Posix.User
@@ -63,6 +64,7 @@ maybeReadFile :: FilePath -> IO (Maybe L.ByteString)
63maybeReadFile path = do 64maybeReadFile path = do
64 doesFileExist path >>= bool (return Nothing) (Just <$> L.readFile path) 65 doesFileExist path >>= bool (return Nothing) (Just <$> L.readFile path)
65myWriteFile f bs = do 66myWriteFile f bs = do
67 createDirectoryIfMissing True (takeDirectory f)
66 hPutStrLn stderr $ "Writing "++f 68 hPutStrLn stderr $ "Writing "++f
67 -- L8.putStr bs 69 -- L8.putStr bs
68 L8.writeFile f bs 70 L8.writeFile f bs
diff --git a/kiki.cabal b/kiki.cabal
index 6723ba4..4f624d6 100644
--- a/kiki.cabal
+++ b/kiki.cabal
@@ -67,6 +67,7 @@ Executable cokiki
67 Main-is: cokiki.hs 67 Main-is: cokiki.hs
68 Build-Depends: base >=4.6.0.0, 68 Build-Depends: base >=4.6.0.0,
69 bytestring, 69 bytestring,
70 filepath,
70 unix, 71 unix,
71 directory, 72 directory,
72 deepseq, 73 deepseq,