packages feed

path 0.5.2 → 0.5.3

raw patch · 5 files changed

+36/−15 lines, 5 files

Files

CHANGELOG view
@@ -1,3 +1,6 @@+0.5.3:+	* Added conversion functions.+ 0.2.0:          * Rename parentAbs to simply parent.
path.cabal view
@@ -1,5 +1,5 @@ name:                path-version:             0.5.2+version:             0.5.3 synopsis:            Path description:         Path license:             BSD3
src/Path.hs view
@@ -31,6 +31,10 @@   ,dirname   -- * Conversion   ,toFilePath+  ,fromAbsDir+  ,fromRelDir+  ,fromAbsFile+  ,fromRelFile   )   where @@ -81,7 +85,7 @@ 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 +100,7 @@ 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 +116,7 @@ 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 +133,7 @@   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 +144,9 @@ -- 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@@ -203,6 +207,22 @@ toFilePath :: Path b t -> FilePath toFilePath (Path l) = l +-- | Convert absolute path to directory to 'FilePath' type.+fromAbsDir :: Path Abs Dir -> FilePath+fromAbsDir = toFilePath++-- | Convert relative path to directory to 'FilePath' type.+fromRelDir :: Path Rel Dir -> FilePath+fromRelDir = toFilePath++-- | Convert absolute path to file to 'FilePath' type.+fromAbsFile :: Path Abs File -> FilePath+fromAbsFile = toFilePath++-- | Convert relative path to file to 'FilePath' type.+fromRelFile :: Path Rel File -> FilePath+fromRelFile = toFilePath+ -------------------------------------------------------------------------------- -- Operations @@ -236,7 +256,7 @@ -- -- The following properties hold: ----- @stripDir parent (parent \<\/> child) = child@+-- @stripDir x (x \<\/> y) = y@ -- -- Cases which are proven not possible: --@@ -266,7 +286,7 @@ -- -- The following properties hold: ----- @parent (parent \<\/> child) == parent@+-- @parent (x \<\/> y) == x@ -- -- On the root, getting the parent is idempotent: --@@ -280,7 +300,7 @@ -- -- The following properties hold: ----- @filename (parent \<\/> filename a) == a@+-- @filename (p \<\/> a) == filename a@ -- filename :: Path b File -> Path Rel File filename (Path l) =@@ -290,7 +310,7 @@ -- -- The following properties hold: ----- @dirname (parent \<\/> dirname a) == a@+-- @dirname (p \<\/> a) == dirname a@ -- dirname :: Path b Dir -> Path Rel Dir dirname (Path l) =
src/Path/Internal.hs view
@@ -1,6 +1,4 @@-{-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}  -- | Internal types and functions. 
test/Main.hs view
@@ -46,7 +46,7 @@              (isNothing (void (parseAbsDir x) <|>                          void (parseRelDir x) <|>                          void (parseAbsFile x) <|>-                         void (parseRelDir x)))+                         void (parseRelFile x)))  -- | The 'filename' operation. operationFilename :: Spec