From 4caacd32c5f2bb140087feee7f17349f7df7a800 Mon Sep 17 00:00:00 2001 From: Gabriel Gonzalez Date: Tue, 24 Feb 2015 09:41:19 -0800 Subject: [PATCH] Some fixes to `deslash` Fixed deslash to not remove the trailing slash if it's also the initial slash Also, I only selectively apply `deslash` for `getDirectoryPermissions` --- src/Turtle/Prelude.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Turtle/Prelude.hs b/src/Turtle/Prelude.hs index 71dd174..65f28c1 100644 --- a/src/Turtle/Prelude.hs +++ b/src/Turtle/Prelude.hs @@ -377,8 +377,8 @@ reparsePoint attr = fILE_ATTRIBUTE_REPARSE_POINT .&. attr /= 0 ls :: FilePath -> Shell FilePath ls path = Shell (\(FoldM step begin done) -> do x0 <- begin - let path' = deslash (Filesystem.encodeString path) - canRead <- fmap readable (getPermissions path') + let path' = Filesystem.encodeString path + canRead <- fmap readable (getPermissions (deslash path')) #ifdef mingw32_HOST_OS reparse <- fmap reparsePoint (Win32.getFileAttributes path') if (canRead && not reparse) @@ -418,8 +418,11 @@ ls path = Shell (\(FoldM step begin done) -> do -} deslash :: String -> String deslash [] = [] -deslash ['\\'] = [] -deslash (c:cs) = c:deslash cs +deslash (c:cs) = c:go cs + where + go [] = [] + go ['\\'] = [] + go (c:cs) = c:go cs -- | Stream all recursive descendents of the given directory lstree :: FilePath -> Shell FilePath