From edb51ad1f60a378aa05460a94281d17d248d7ea5 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sat, 26 Dec 2015 15:58:41 +0100 Subject: [PATCH] LIB: add createDir --- src/IO/File.hs | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/src/IO/File.hs b/src/IO/File.hs index 6b53fc1..375be70 100644 --- a/src/IO/File.hs +++ b/src/IO/File.hs @@ -404,17 +404,20 @@ createFile _ ".." = return () createFile (SADir td) fn = do let fullp = fullPath td fn throwFileDoesExist fullp - let uf = unionFileModes - mode = ownerWriteMode - `uf` ownerReadMode - `uf` groupWriteMode - `uf` groupReadMode - `uf` otherWriteMode - `uf` otherReadMode - fd <- System.Posix.IO.createFile fullp mode + fd <- System.Posix.IO.createFile fullp newFilePerms closeFd fd +createDir :: AnchoredFile FileInfo -> FileName -> IO () +createDir _ "" = return () +createDir _ "." = return () +createDir _ ".." = return () +createDir (SADir td) fn = do + let fullp = fullPath td fn + throwDirDoesExist fullp + createDirectory fullp newFilePerms + + --------------------- @@ -433,3 +436,29 @@ renameFile af fn = do throwFileDoesExist tof throwSameFile fromf tof rename fromf tof + + + + ----------------------- + --[ File Permissions]-- + ----------------------- + + +newFilePerms :: FileMode +newFilePerms + = ownerWriteMode + `unionFileModes` ownerReadMode + `unionFileModes` groupWriteMode + `unionFileModes` groupReadMode + `unionFileModes` otherWriteMode + `unionFileModes` otherReadMode + + +newDirPerms :: FileMode +newDirPerms + = ownerModes + `unionFileModes` groupExecuteMode + `unionFileModes` groupReadMode + `unionFileModes` otherExecuteMode + `unionFileModes` otherReadMode +