Skip to content

Commit

Permalink
Use Setup.hs to get sdist list + add tar.gz code #313
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Jul 18, 2015
1 parent 09a9fa4 commit 1fe6dc8
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 149 deletions.
25 changes: 25 additions & 0 deletions src/Path/IO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

module Path.IO
(getWorkingDir
,makeAbsolute
,parseRelAsAbsDir
,parseRelAsAbsFile
,listDirectory
,resolveDir
,resolveFile
Expand Down Expand Up @@ -58,6 +61,28 @@ instance Show ResolveException where
getWorkingDir :: (MonadIO m) => m (Path Abs Dir)
getWorkingDir = liftIO (D.canonicalizePath "." >>= parseAbsDir)

-- | Take a relative path and base it off the working directory,
-- yielding an absolute path.
makeAbsolute :: MonadIO m => Path Rel a -> m (Path Abs a)
makeAbsolute rel = liftM (</> rel) getWorkingDir

-- | Parse a directory path. If the path is absolute, it's directly
-- yielded. If it's relative, then 'makeAbsolute' is used to base it
-- off the working directory.
parseRelAsAbsDir :: (MonadThrow m, MonadIO m) => FilePath -> m (Path Abs Dir)
parseRelAsAbsDir "." = getWorkingDir
parseRelAsAbsDir fp
| FP.isAbsolute fp = parseAbsDir fp
| otherwise = makeAbsolute =<< parseRelDir fp

-- | Parse a file path. If the path is absolute, it's directly yielded.
-- If it's relative, then 'makeAbsolute' is used to base it off the
-- working directory.
parseRelAsAbsFile :: (MonadThrow m, MonadIO m) => FilePath -> m (Path Abs File)
parseRelAsAbsFile fp
| FP.isAbsolute fp = parseAbsFile fp
| otherwise = makeAbsolute =<< parseRelFile fp

-- | Appends a stringly-typed relative path to an absolute path, and then
-- canonicalizes it.
resolveDir :: (MonadIO m, MonadThrow m) => Path Abs Dir -> FilePath -> m (Path Abs Dir)
Expand Down
Loading

0 comments on commit 1fe6dc8

Please sign in to comment.