Skip to content

Commit aabde18

Browse files
committed
Move FilePathPart from Path.hs to Nar.hs.
This has nothing to do with store paths...
1 parent 03d9a21 commit aabde18

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

hnix-store-core/src/System/Nix/Nar.hs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ module System.Nix.Nar (
1818
, localUnpackNar
1919
, narEffectsIO
2020
, putNar
21+
, FilePathPart(..)
22+
, filePathPart
2123
) where
2224

2325
import Control.Applicative
@@ -42,7 +44,6 @@ import System.FilePath
4244
import System.Posix.Files (createSymbolicLink, fileSize, getFileStatus,
4345
isDirectory, readSymbolicLink)
4446

45-
import System.Nix.Path
4647

4748
data NarEffects (m :: * -> *) = NarEffects {
4849
narReadFile :: FilePath -> m BSL.ByteString
@@ -65,6 +66,17 @@ data NarEffects (m :: * -> *) = NarEffects {
6566
data Nar = Nar { narFile :: FileSystemObject }
6667
deriving (Eq, Show)
6768

69+
-- | A valid filename or directory name
70+
newtype FilePathPart = FilePathPart { unFilePathPart :: BSC.ByteString }
71+
deriving (Eq, Ord, Show)
72+
73+
-- | Construct FilePathPart from Text by checking that there
74+
-- are no '/' or '\\NUL' characters
75+
filePathPart :: BSC.ByteString -> Maybe FilePathPart
76+
filePathPart p = case BSC.any (`elem` ['/', '\NUL']) p of
77+
False -> Just $ FilePathPart p
78+
True -> Nothing
79+
6880
-- | A FileSystemObject (FSO) is an anonymous entity that can be NAR archived
6981
data FileSystemObject =
7082
Regular IsExecutable Int64 BSL.ByteString

hnix-store-core/src/System/Nix/Path.hs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ Maintainer : Shea Levy <[email protected]>
66
{-# LANGUAGE OverloadedStrings #-}
77
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
88
module System.Nix.Path
9-
( FilePathPart(..)
10-
, PathHashAlgo
9+
( PathHashAlgo
1110
, Path(..)
1211
, pathToText
1312
, PathSet
1413
, SubstitutablePathInfo(..)
1514
, ValidPathInfo(..)
1615
, PathName(..)
17-
, filePathPart
1816
, pathName
1917
, Roots
2018
) where
@@ -111,17 +109,6 @@ data ValidPathInfo = ValidPathInfo
111109
ca :: !Text
112110
} deriving (Eq, Ord, Show)
113111

114-
-- | A valid filename or directory name
115-
newtype FilePathPart = FilePathPart { unFilePathPart :: BSC.ByteString }
116-
deriving (Eq, Ord, Show)
117-
118-
-- | Construct FilePathPart from Text by checking that there
119-
-- are no '/' or '\\NUL' characters
120-
filePathPart :: BSC.ByteString -> Maybe FilePathPart
121-
filePathPart p = case BSC.any (`elem` ['/', '\NUL']) p of
122-
False -> Just $ FilePathPart p
123-
True -> Nothing
124-
125112
type Roots = Map Path Path
126113

127114
instance Hashable Path where

0 commit comments

Comments
 (0)