Move FilePathPart from Path.hs to Nar.hs.

This has nothing to do with store paths...
This commit is contained in:
Shea Levy 2019-03-22 08:57:51 -04:00
parent 03d9a212e8
commit aabde18a4a
No known key found for this signature in database
GPG Key ID: 5C0BD6957D86FE27
2 changed files with 14 additions and 15 deletions

View File

@ -18,6 +18,8 @@ module System.Nix.Nar (
, localUnpackNar
, narEffectsIO
, putNar
, FilePathPart(..)
, filePathPart
) where
import Control.Applicative
@ -42,7 +44,6 @@ import System.FilePath
import System.Posix.Files (createSymbolicLink, fileSize, getFileStatus,
isDirectory, readSymbolicLink)
import System.Nix.Path
data NarEffects (m :: * -> *) = NarEffects {
narReadFile :: FilePath -> m BSL.ByteString
@ -65,6 +66,17 @@ data NarEffects (m :: * -> *) = NarEffects {
data Nar = Nar { narFile :: FileSystemObject }
deriving (Eq, Show)
-- | A valid filename or directory name
newtype FilePathPart = FilePathPart { unFilePathPart :: BSC.ByteString }
deriving (Eq, Ord, Show)
-- | Construct FilePathPart from Text by checking that there
-- are no '/' or '\\NUL' characters
filePathPart :: BSC.ByteString -> Maybe FilePathPart
filePathPart p = case BSC.any (`elem` ['/', '\NUL']) p of
False -> Just $ FilePathPart p
True -> Nothing
-- | A FileSystemObject (FSO) is an anonymous entity that can be NAR archived
data FileSystemObject =
Regular IsExecutable Int64 BSL.ByteString

View File

@ -6,15 +6,13 @@ Maintainer : Shea Levy <shea@shealevy.com>
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module System.Nix.Path
( FilePathPart(..)
, PathHashAlgo
( PathHashAlgo
, Path(..)
, pathToText
, PathSet
, SubstitutablePathInfo(..)
, ValidPathInfo(..)
, PathName(..)
, filePathPart
, pathName
, Roots
) where
@ -111,17 +109,6 @@ data ValidPathInfo = ValidPathInfo
ca :: !Text
} deriving (Eq, Ord, Show)
-- | A valid filename or directory name
newtype FilePathPart = FilePathPart { unFilePathPart :: BSC.ByteString }
deriving (Eq, Ord, Show)
-- | Construct FilePathPart from Text by checking that there
-- are no '/' or '\\NUL' characters
filePathPart :: BSC.ByteString -> Maybe FilePathPart
filePathPart p = case BSC.any (`elem` ['/', '\NUL']) p of
False -> Just $ FilePathPart p
True -> Nothing
type Roots = Map Path Path
instance Hashable Path where