From 733fa04ac31e4c94f468a5a5cdab79725367b52e Mon Sep 17 00:00:00 2001 From: mrkkrp Date: Sat, 21 Nov 2015 16:14:54 +0600 Subject: [PATCH] =?UTF-8?q?Write=20=E2=80=98isPrefixOf=E2=80=99=20and=20fr?= =?UTF-8?q?iends=20in=20infix=20form?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Path.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Path.hs b/src/Path.hs index 2cdf467..9a7b76c 100644 --- a/src/Path.hs +++ b/src/Path.hs @@ -81,7 +81,7 @@ parseAbsDir :: MonadThrow m parseAbsDir filepath = if FilePath.isAbsolute filepath && not (null (normalizeDir filepath)) && - not (isPrefixOf "~/" filepath) && + not ("~/" `isPrefixOf` filepath) && not (hasParentDir filepath) then return (Path (normalizeDir filepath)) else throwM (InvalidAbsDir filepath) @@ -96,7 +96,7 @@ parseRelDir :: MonadThrow m parseRelDir filepath = if not (FilePath.isAbsolute filepath) && not (null filepath) && - not (isPrefixOf "~/" filepath) && + not ("~/" `isPrefixOf` filepath) && not (hasParentDir filepath) && not (null (normalizeDir filepath)) && filepath /= ".." @@ -112,7 +112,7 @@ parseAbsFile :: MonadThrow m parseAbsFile filepath = if FilePath.isAbsolute filepath && not (FilePath.hasTrailingPathSeparator filepath) && - not (isPrefixOf "~/" filepath) && + not ("~/" `isPrefixOf` filepath) && not (hasParentDir filepath) && not (null (normalizeFile filepath)) && filepath /= ".." @@ -129,7 +129,7 @@ parseRelFile filepath = if not (FilePath.isAbsolute filepath || FilePath.hasTrailingPathSeparator filepath) && not (null filepath) && - not (isPrefixOf "~/" filepath) && + not ("~/" `isPrefixOf` filepath) && not (hasParentDir filepath) && not (null (normalizeFile filepath)) && filepath /= ".." @@ -140,9 +140,9 @@ parseRelFile filepath = -- This handles the logic of checking for different path separators on Windows. hasParentDir :: FilePath -> Bool hasParentDir filepath' = - (isSuffixOf "/.." filepath) || - (isInfixOf "/../" filepath) || - (isPrefixOf "../" filepath) + ("/.." `isSuffixOf` filepath) || + ("/../" `isInfixOf` filepath) || + ("../" `isPrefixOf` filepath) where filepath = case FilePath.pathSeparator of