Commit Graph

38 Commits

Author SHA1 Message Date
3c5f06f41d
Remove redundant imports in tests 2018-07-19 13:33:55 +08:00
3e6d93182a
Abstract over Path more properly
We don't expect "Path Abs" everywhere anymore. The functions
have been made to be more generic. A user can still pass
absolute paths, so we don't lose any safety. However, some
function implementations may be more tricky.
2018-04-11 01:11:00 +02:00
0ec2cf8ca5 Add writeFile and appendFile 2018-04-06 17:22:38 +02:00
9ac10a6a7d Add file reading functions 2018-04-06 16:42:40 +02:00
3baecb7b51
Improve CopyDirRecursiveCollectFailures tests 2016-06-14 19:32:33 +02:00
ef66a24f87
Improve error handling
* remove some obsolete functions and error types from HPath.IO.Errors
  that are completely unused
* reworked the RecursiveFailure type to contain more information,
  so we can use it to programmatically make useful choices
  without examining the weakly types IO error attributes (like
  'ioGetFileName')
2016-06-14 19:13:25 +02:00
5b08e14b55
Add createDirRecursive, fixes #6 2016-06-13 01:28:55 +02:00
a31c9d1e88
Improve documentation and tests for file creation 2016-06-05 21:59:31 +02:00
a5942ff026
Use IfElse package for whenM/unlessM 2016-06-05 21:52:52 +02:00
92017ab630
Make createRegularFile and createDir accept FileMode parameter 2016-06-05 17:46:25 +02:00
a1eb06324f
Rm unused imports 2016-06-05 16:09:34 +02:00
d12ce30f57
Fix docs and rename RecursiveMode to RecursiveErrorMode 2016-06-05 16:07:46 +02:00
d708f80a1f
TESTS: don't assume ordering of exceptions 2016-06-05 15:37:26 +02:00
f07619b7c6
TESTS: fix before/after 2016-06-05 15:25:57 +02:00
c5bcb90b65
TESTS: don't use lazy IO -.- 2016-06-05 14:55:21 +02:00
4f047dbc77
TESTS: import unsafePerformIO from System.IO.Unsafe 2016-06-05 14:46:45 +02:00
bc348c7dd5
TESTS: less side effects plz 2016-06-05 14:33:53 +02:00
5d1c5cc2ce
Fix linter warning 2016-06-05 03:26:05 +02:00
8f6ca81d22
Add tests to RecreateSymlinkOverwriteSpec 2016-06-05 03:22:35 +02:00
64ae6db83a
New API: use CopyMode for overwriting and introduce RecursiveMode
This allows to specify the behavior on recursive operations,
such that one can collect failures instead of dying on the first
failure.
2016-06-05 03:13:33 +02:00
8d948366f9
Add hspec for createSymlink 2016-05-29 17:43:43 +02:00
1b9b8cc886
Set test formatter to progress 2016-05-29 17:32:22 +02:00
395621b27a
Fix tests for sdist
We now create the necessary directories and files
for the tests on-the-fly.
2016-05-29 17:29:13 +02:00
930b021a32
Add missing (<$>) imports 2016-05-09 18:53:26 +02:00
86a4b9ade2
Add IO modules, previously from HSFM 2016-05-09 16:53:31 +02:00
7e8c745e35
Clean up, rewrite stuff 2016-04-16 18:17:44 +02:00
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
Chris Done
62c681819c Update test suite 2016-03-04 15:09:21 +01:00
Chris Done
04608e0e53 Reject only .. and . (#13) 2016-03-04 15:06:27 +01:00
Chris Done
2e109c86d8 Reject path consisting of all "." (fixes #13)
Ping @mrkkrp
2016-03-04 14:39:17 +01:00
Magnus Therning
b5cff315a1 Clarify what limitations the RelX parsers have.
Signed-off-by: Magnus Therning <magnus@therning.org>
2016-01-07 16:15:06 +01:00
Ethan Glasser-Camp
a4ed4cd504 test: missing case for parseRelFile 2015-07-08 20:28:15 -04:00
Chris Done
4e1816392a Fix stripDir p p /= Nothing bug 2015-05-27 17:08:03 +02:00
Chris Done
87a56a93b8 Disallow .. 2015-05-22 11:35:52 +02:00
Chris Done
a68b46b060 Update test suite 2015-05-11 19:01:35 +02:00
Chris Done
ef8503f38f Rename parentAbs to parent 2015-05-11 18:40:54 +02:00
Chris Done
c4895949ee Add some operations 2015-05-08 14:03:37 +02:00
Chris Done
1e5b6675c2 Basic Path type with parsers and test suite 2015-05-08 13:14:54 +02:00