Commit Graph

32 Commits

Author SHA1 Message Date
Julian Ospald 809ffc7745
Add unsafeToString methods 2018-07-23 10:21:17 +08:00
Julian Ospald d9ba67b6f0
Fix build with ghc-7.6 2018-04-12 01:41:32 +02:00
Julian Ospald 1a2c77c6a6
dirname: remove incorrect documentation on properties
Fixes #11
2017-01-14 20:16:25 +01:00
Julian Ospald f6a5cb8668
Add test to basename 2016-06-13 13:51:53 +02:00
Julian Ospald 08de2ebefb
Move RelC class from HPath.Internal to HPath 2016-05-30 13:02:34 +02:00
Julian Ospald 21fccc9ca9
Fix build with ghc < 7.10 2016-05-29 18:57:55 +02:00
Julian Ospald 79dbcd8b55
Add type signature to pattern synonym 2016-05-29 17:56:51 +02:00
Julian Ospald 5ac7450495
Small import fix 2016-05-24 03:26:07 +02:00
Julian Ospald 908513da2b
Prettify doctests 2016-05-23 00:52:27 +02:00
Julian Ospald 797dcaf725
Backport changes from posix-paths PR:
* add isFileName
* add hasParentDir
* add hiddenFile
* add our own openFd version for more control
* small documentation improvements
* add a getDirectoryContents' version that works on Fd
* fix linting warnings
* lift version constraints in benchmark

Also adjust HPath.IO to work with the new API.
2016-05-18 04:11:40 +02:00
Julian Ospald 78a3baeb25
Export PathException 2016-05-09 19:34:19 +02:00
Julian Ospald a83e96259f
Fix build with bytestring >= 0.10.8 2016-05-09 18:17:33 +02:00
Julian Ospald f27becc4df
Cleanup, improve docs 2016-05-09 17:37:16 +02:00
Julian Ospald 3bbde22377
Add 'hiddenFile' to System.Posix.FilePath 2016-05-09 17:37:00 +02:00
Julian Ospald 3da8533b48
Remove 'normalize' from HPath, since it's not needed 2016-05-09 17:04:26 +02:00
Julian Ospald 196647a383
Move some functionality from HPath to System.Posix.FilePath
This also removes 'canonicalizePath' from HPath which fixes
the doctest.
2016-05-09 14:16:53 +02:00
Julian Ospald 45b515d1db
Add withAbsPath/withRelPath/withFnPath 2016-04-17 18:09:50 +02:00
Julian Ospald a5360f29a3
Don't re-export functions 2016-04-16 19:21:19 +02:00
Julian Ospald f1875da780
Use latest posix-paths
Pending upstream PR.
2016-04-16 19:12:23 +02:00
Julian Ospald 7e8c745e35
Clean up, rewrite stuff 2016-04-16 18:17:44 +02:00
Julian Ospald 577ecf6750
Add normalizeAbs, which may or may not be useful 2016-04-15 14:23:25 +02:00
Julian Ospald 8f7e5806e3
Be more strict
* don't rely on OverloadedString
* make basename fail if run on root dir "/"
* reject "." and ".." in filename parser
* reject ".." in path parsers
* normalise paths in parsers
2016-04-15 14:23:07 +02:00
Julian Ospald c570505297
Add hiddenFile function 2016-04-10 21:50:52 +02:00
Julian Ospald 148eeb619f
Implement String -> ByteString and vice versa conversion for filepaths 2016-04-05 00:55:25 +02:00
Julian Ospald 877d8c4089
Implement equalFilePath 2016-04-05 00:54:55 +02:00
Julian Ospald 8c1bd139c0
Readd TH constructors 2016-04-05 00:54:36 +02:00
Julian Ospald bd71947b2a
Use word8 package 2016-04-04 18:46:25 +02:00
Julian Ospald 491efe44a3
Use ByteString for paths instead of String 2016-04-04 17:29:35 +02:00
hasufell c7229061d0 Fix encoding issues with realPath 2016-04-04 03:06:22 +02:00
Julian Ospald 3a52a9ea4b
Add getAllParents 2016-04-03 16:20:38 +02:00
Julian Ospald 3c3a2d2766
Switch to new layout 2016-03-30 02:47:42 +02:00
Julian Ospald d15e4b8ad9 Fork chrisdone's path library
I wasn't happy with the way it dealt with Dir vs File things. In his
version of the library, a `Path b Dir` always ends with a trailing
path separator and `Path b File` never ends with a trailing path separator.

IMO, it is nonsensical to make a Dir vs File distinction on path level,
although it first seems nice.
Some of the reasons are:
* a path is just that: a path. It is completely disconnected from IO level
  and even if a `Dir`/`File` type theoretically allows us to say "this path
  ought to point to a file", there is literally zero guarantee that it will
  hold true at runtime. So this basically gives a false feeling of a
  type-safe file distinction.
* it's imprecise about Dir vs File distinction, which makes it even worse,
  because a directory is also a file (just not a regular file). Add symlinks
  to that and the confusion is complete.
* it makes the API oddly complicated for use cases where we basically don't
  care (yet) whether something turns out to be a directory or not

Still, it comes also with a few perks:
* it simplifies some functions, because they now have guarantees whether a
  path ends in a trailing path separator or not
* it may be safer for interaction with other library functions, which behave
  differently depending on a trailing path separator (like probably shelly)

Not limited to, but also in order to fix my remarks without breaking any
benefits, I did:
* rename the `Dir`/`File` types to `TPS`/`NoTPS`, so it's clear we are only
  giving information about trailing path separators and not actual file
  types we don't know about yet
* add a `MaybeTPS` type, which does not mess with trailing path separators
  and also gives no guarantees about them... then added `toNoTPS` and
  `toTPS` to allow type-safe conversion
* make some functions accept more general types, so we don't unnecessarily
  force paths with trailing separators for `(</>)` for example... instead
  these functions now examine the paths to still have correct behavior.
  This is really minor overhead. You might say now "but then I can append
  filepath to filepath". Well, as I said... we don't know whether it's a
  "filepath" at all.
* merge `filename` and `dirname` into `basename` and make `parent` be
  `dirname`, so the function names match the name of the POSIX ones,
  which do (almost) the same...
* fix a bug in `basename` (formerly `dirname`) which broke the type
  guarantees
* add a pattern synonym for easier pattern matching without exporting
  the internal Path constructor
2016-03-08 22:53:42 +01:00