From 2bc406f65e2b4d9a88128e6f1f7e8d062ac9e14e Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Wed, 30 Dec 2015 02:32:48 +0100 Subject: [PATCH] LIB: fix file type indicators It seems that PF.regularFileMode matches across symlinks and sockets too, so we just examine the constructors instead. Fixes #25 --- src/Data/DirTree.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Data/DirTree.hs b/src/Data/DirTree.hs index 2f79525..f44c654 100644 --- a/src/Data/DirTree.hs +++ b/src/Data/DirTree.hs @@ -784,14 +784,14 @@ packPermissions dt = fromFreeVar (pStr . fileMode) dt where pStr ffm = typeModeStr ++ ownerModeStr ++ groupModeStr ++ otherModeStr where - typeModeStr - | hasFM PF.regularFileMode = "-" - | hasFM PF.directoryMode = "d" - | hasFM PF.symbolicLinkMode = "l" - | hasFM PF.socketMode = "s" - | hasFM PF.blockSpecialMode = "b" - | hasFM PF.characterSpecialMode = "c" - | hasFM PF.namedPipeMode = "p" + typeModeStr = case dt of + Dir {} -> "d" + RegFile {} -> "-" + SymLink {} -> "l" + BlockDev {} -> "b" + CharDev {} -> "c" + NamedPipe {} -> "p" + Socket {} -> "s" ownerModeStr = hasFmStr PF.ownerReadMode "r" ++ hasFmStr PF.ownerWriteMode "w" ++ hasFmStr PF.ownerExecuteMode "x"