File: README.md

package info (click to toggle)
haskell-hslua-module-zip 1.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 100 kB
  • sloc: haskell: 304; makefile: 3
file content (159 lines) | stat: -rw-r--r-- 3,588 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# hslua-module-zip

[![GitHub CI][CI badge]](https://github.com/hslua/hslua/actions)
[![Hackage][Hackage badge]](https://hackage.haskell.org/package/hslua-module-zip)
[![Stackage Lts][Stackage Lts badge]](http://stackage.org/lts/package/hslua-module-zip)
[![Stackage Nightly][Stackage Nightly badge]](http://stackage.org/nightly/package/hslua-module-zip)
[![MIT license][License badge]](LICENSE)

[CI badge]: https://img.shields.io/github/workflow/status/hslua/hslua/CI.svg?logo=github
[Hackage badge]: https://img.shields.io/hackage/v/hslua-module-zip.svg?logo=haskell
[Stackage Lts badge]: http://stackage.org/package/hslua-module-zip/badge/lts
[Stackage Nightly badge]: http://stackage.org/package/hslua-module-zip/badge/nightly
[License badge]: https://img.shields.io/badge/license-MIT-blue.svg

Lua module to work with file zips.

## zip

Functions to create, modify, and extract files from zip archives.

The module can be called as a function, in which case it behaves
like the `zip` function described below.

Zip options are optional; when defined, they must be a table with
any of the following keys:

  - `recursive`: recurse directories when set to `true`;
  - `verbose`: print info messages to stdout;
  - `destination`: the value specifies the directory in which to extract;
  - `location`: value is used as path name, defining where files
    are placed.
  - `preserve_symlinks`: Boolean value, controlling whether
    symbolic links are preserved as such. This option is ignored
    on Windows.

## Functions

### Archive

`Archive (bytestring_or_entries)`

Reads an *Archive* structure from a raw zip archive or a list of
Entry items; throws an error if the given string cannot be decoded
into an archive.

*Since: 1.0.0*

Parameters:

bytestring_or_entries
:    (string|{ZipEntry,...})

Returns:

 -   (ZipArchive)

### Entry

`Entry (path, contents[, modtime])`

Generates a zip Entry from a filepath, the file's uncompressed
content, and the file's modification time.

*Since: 1.0.0*

Parameters:

path
:   file path in archive (string)

contents
:   uncompressed contents (string)

modtime
:   modification time (integer)

### read_entry

`read_entry (filepath, opts)`

Generates a ZipEntry from a file or directory.

*Since: 1.0.0*

Parameters:

filepath
:    (string)

opts
:   zip options (table)

Returns:

 -  a new zip archive entry (ZipEntry)

### zip

`zip (filepaths[, options])`

Package and compress the given files into a new Archive.

*Since: 1.0.0*

Parameters:

filepaths
:    list of files from which the archive is created. ({string,...})

options
:   zip options (table)

Returns:

 -  a new archive (ZipArchive)

## Types

### Archive

A zip archive with file entries.

#### Fields

`entries`
:   files in this zip archive ({Entry,...})

#### Methods

`extract([opts])`
:   Extract all files from this archive, creating directories as
    needed. Note that the last-modified time is set correctly only
    in POSIX, not in Windows. This function fails if encrypted
    entries are present.

    Use `archive:extract{destination = 'dir'}` to extract to
    subdirectory `dir`.

`bytestring()`
:   Returns the raw binary string representation of the archive.

### Entry

File or directory entry in a zip archive.

#### Fields:

`path`
:   relative path, using `/` as separator

`modtime`
:   modification time (seconds since unix epoch)

#### Methods:

`contents([password])`
:   Get the uncompressed contents of a zip entry. If `password` is
    given, then that password is used to decrypt the contents. An
    error is throws if decrypting fails.