diff options
Diffstat (limited to 'stdlib/source/library/lux/data/format/tar.lux')
-rw-r--r-- | stdlib/source/library/lux/data/format/tar.lux | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index c98ef6ee5..6e5293f67 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -16,7 +16,7 @@ ["[1]!" \\unsafe] ["![1]" \\format (.only Format) (.use "[1]#[0]" monoid)] ["?[1]" \\parser (.only Parser)]] - ["[0]" text (.only) + ["[0]" text (.use "[1]#[0]" equivalence) [char (.only Char)] ["%" \\format] [encoding @@ -504,8 +504,6 @@ (def maximum_mode Mode (all and - ..none - ..execute_by_other ..write_by_other ..read_by_other @@ -610,6 +608,33 @@ (type .public Tar (Sequence Entry)) +(exception.def .public (unknown_file path) + (Exception Path) + (exception.report + (list ["Path" (%.text (from_path path))]))) + +(def .public (file expected it) + (-> Path Tar + (Try Binary)) + (when (sequence.one (function (_ it) + (when it + (^.or {#Normal it} + {#Contiguous it}) + (let [[actual _ _ _ content] it] + (if (text#= (from_path expected) + (from_path actual)) + {.#Some (data content)} + {.#None})) + + _ + {.#None})) + it) + {.#Some it} + {try.#Success it} + + {.#None} + (exception.except ..unknown_file [expected]))) + (def (blocks size) (-> Big Nat) (n.+ (n./ ..block_size |