Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
OsPath.Internal.Posix
Description
Internal types and functions.
Synopsis
- newtype Path b t = Path PosixPath
- toOsPath :: Path b t -> PosixPath
- isValidAbsDir :: PosixPath -> Bool
- isValidAbsFile :: PosixPath -> Bool
- isValidRelDir :: PosixPath -> Bool
- isValidRelFile :: PosixPath -> Bool
- hasParentDir :: PosixPath -> Bool
- normalizeLeadingSeps :: PosixPath -> PosixPath
- normalizeTrailingSeps :: PosixPath -> PosixPath
- normalizeAllSeps :: PosixPath -> PosixPath
- normalizeDrive :: PosixPath -> PosixPath
- normalizeDir :: PosixPath -> PosixPath
- normalizeFile :: PosixPath -> PosixPath
- extSep :: PosixString
- pathSep :: PosixString
- relRoot :: PosixPath
- isWindows :: Bool
The Path type
Path of some base and type.
The type variables are:
b
— base, the base location of the path; absolute or relative.t
— type, whether file or directory.
Internally it is a PosixPath
, which can be of two formats only:
- File format:
file.txt
,foo/bar.txt
,/foo/bar.txt
- Directory format:
foo/
,/foo/bar/
All directories end in a trailing separator. There are no duplicate
path separators //
, no ..
, no ./
, no ~/
, etc.
Instances
(Typeable b, Typeable t) => Lift (Path b t :: Type) Source # | |
(Data b, Data t) => Data (Path b t) Source # | |
Defined in OsPath.Internal.Posix Methods gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Path b t -> c (Path b t) # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Path b t) # toConstr :: Path b t -> Constr # dataTypeOf :: Path b t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (Path b t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (Path b t)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> Path b t -> Path b t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Path b t -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Path b t -> r # gmapQ :: (forall d. Data d => d -> u) -> Path b t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Path b t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Path b t -> m (Path b t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Path b t -> m (Path b t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Path b t -> m (Path b t) # | |
Generic (Path b t) Source # | |
Show (Path b t) Source # | Same as 'show . OsPath.toOsPath'. The following property holds: x == y ≡ show x == show y |
NFData (Path b t) Source # | |
Defined in OsPath.Internal.Posix | |
Eq (Path b t) Source # | String equality. The following property holds: show x == show y ≡ x == y |
Ord (Path b t) Source # | String ordering. The following property holds: show x `compare` show y ≡ x `compare` y |
Defined in OsPath.Internal.Posix | |
Hashable (Path b t) Source # | |
Defined in OsPath.Internal.Posix | |
type Rep (Path b t) Source # | |
Defined in OsPath.Internal.Posix |
toOsPath :: Path b t -> PosixPath Source #
Convert to a PosixPath type.
All directories have a trailing slash, so if you want no trailing
slash, you can use dropTrailingPathSeparator
from
the filepath package.
Validation functions
hasParentDir :: PosixPath -> Bool Source #
Helper function: check if the filepath has any parent directories in it. This handles the logic of checking for different path separators on Windows.
Normalizing functions
normalizeLeadingSeps :: PosixPath -> PosixPath Source #
Normalizes seps only at the beginning of a path.
normalizeTrailingSeps :: PosixPath -> PosixPath Source #
Normalizes seps only at the end of a path.
normalizeAllSeps :: PosixPath -> PosixPath Source #
Replaces consecutive path seps with single sep and replaces alt sep with standard sep.
normalizeDir :: PosixPath -> PosixPath Source #
Normalizes directory path with platform-specific rules.
normalizeFile :: PosixPath -> PosixPath Source #
Applies platform-specific sep normalization following OsPath.normalise
.
Other helper functions
extSep :: PosixString Source #