You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 22, 2021. It is now read-only.
This module provides access to system information and functionality via
5
4
Haskell's `System` module.
@@ -8,9 +7,7 @@ Intended usage for this package is to preload it by adding the loader
8
7
function to `package.preload`. Note that the Lua `package` library must
9
8
have already been loaded before the loader can be added.
10
9
11
-
12
-
Example
13
-
-------
10
+
## Example
14
11
15
12
```haskell
16
13
loadProg::LuaStatus
@@ -22,31 +19,29 @@ loadProg = do
22
19
++"system.with_tmpdir('.', 'foo', print)"
23
20
```
24
21
22
+
## Documentation
25
23
26
-
Documentation
27
-
-------------
28
-
29
-
## Fields
24
+
### Fields
30
25
31
-
### arch
26
+
####arch
32
27
33
28
The machine architecture on which the program is running.
34
29
35
-
### compiler_name
30
+
####compiler_name
36
31
37
32
The Haskell implementation with which the host program was compiled.
38
33
39
-
### compiler_version
34
+
####compiler_version
40
35
41
36
The version of `compiler_name` with which the host program was compiled.
42
37
43
-
### os
38
+
####os
44
39
45
40
The operating system on which the program is running.
46
41
47
-
## Functions
42
+
### General Functions
48
43
49
-
### env
44
+
####env
50
45
51
46
`env ()`
52
47
@@ -57,7 +52,7 @@ Returns:
57
52
- A table mapping environment variables names to their string value
58
53
(table).
59
54
60
-
### getenv
55
+
####getenv
61
56
62
57
`getenv (var)`
63
58
@@ -74,7 +69,7 @@ Returns:
74
69
- value of the variable, or nil if the variable is not defined (string
75
70
or nil).
76
71
77
-
### getwd
72
+
####getwd
78
73
79
74
`getwd ()`
80
75
@@ -84,7 +79,7 @@ Returns:
84
79
85
80
- The current working directory (string).
86
81
87
-
### ls
82
+
####ls
88
83
89
84
`ls ([directory])`
90
85
@@ -101,7 +96,7 @@ Returns:
101
96
- A table of all entries in `directory` without the special entries (`.`
102
97
and `..`).
103
98
104
-
### mkdir
99
+
####mkdir
105
100
106
101
`mkdir (dirname [, create_parent])`
107
102
@@ -123,7 +118,7 @@ Parameters:
123
118
`create_parent`
124
119
: create parent directories if necessary
125
120
126
-
### rmdir
121
+
####rmdir
127
122
128
123
`rmdir (dirname [, recursive])`
129
124
@@ -138,7 +133,7 @@ Parameters:
138
133
`recursive`
139
134
: delete content recursively
140
135
141
-
### setenv
136
+
####setenv
142
137
143
138
`setenv (var, value)`
144
139
@@ -152,7 +147,7 @@ Parameters:
152
147
`value`
153
148
: new value (string).
154
149
155
-
### setwd
150
+
####setwd
156
151
157
152
`setwd (directory)`
158
153
@@ -164,7 +159,7 @@ Parameters:
164
159
: Path of the directory which is to become the new working
165
160
directory (string)
166
161
167
-
### tmpdirname
162
+
####tmpdirname
168
163
169
164
`tmpdirname ()`
170
165
@@ -189,7 +184,7 @@ Returns:
189
184
190
185
- The current directory for temporary files (string).
191
186
192
-
### with\_env
187
+
####with\_env
193
188
194
189
`with_env (environment, callback)`
195
190
@@ -211,9 +206,9 @@ Parameters:
211
206
212
207
Returns:
213
208
214
-
-The result(s) of the call to `callback`
209
+
- The result(s) of the call to `callback`
215
210
216
-
### with\_tmpdir
211
+
####with\_tmpdir
217
212
218
213
`with_tmpdir ([parent_dir,] templ, callback)`
219
214
@@ -236,9 +231,9 @@ Parameters:
236
231
237
232
Returns:
238
233
239
-
-The result of the call to `callback`.
234
+
- The result of the call to `callback`.
240
235
241
-
### with\_wd
236
+
####with\_wd
242
237
243
238
`with_wd (directory, callback)`
244
239
@@ -258,11 +253,223 @@ Parameters:
258
253
259
254
Returns:
260
255
261
-
- The result(s) of the call to `callback`
256
+
- The result(s) of the call to `callback`
257
+
258
+
### Path Manipulation Functions
259
+
260
+
This library includes wrappers around the following functions from the [filepath](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath.html) library for the current platform (POSIX or Windows). All examples below are for [POSIX systems](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html).
261
+
262
+
#### take_directory
263
+
264
+
`take_directory(filepath)`
265
+
266
+
Get the directory name, move up one level.
267
+
268
+
```lua
269
+
takeDirectory("/foo/bar/baz") =="/foo/bar"
270
+
takeDirectory("/foo/bar/baz/") =="/foo/bar/baz"
271
+
```
272
+
273
+
Parameters:
274
+
275
+
`filepath`
276
+
: path path
277
+
278
+
Returns:
279
+
280
+
- The modified filepath.
281
+
282
+
This function wraps [System.FilePath.takeDirectory](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:takeDirectory).
283
+
284
+
#### take_filename
285
+
286
+
`take_filename(filepath)`
287
+
288
+
Get the file name.
289
+
290
+
```lua
291
+
takeFileName("/directory/file.ext") =="file.ext"
292
+
takeFileName("test/") ==""
293
+
```
294
+
295
+
Parameters:
296
+
297
+
`filepath`
298
+
: path
299
+
300
+
Returns:
301
+
302
+
- The file name.
303
+
304
+
This function wraps [System.FilePath.takeFileName](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:takeFileName).
305
+
306
+
#### take_extensions
307
+
308
+
`take_extensions(filepath)`
309
+
310
+
Get all extensions.
311
+
312
+
```lua
313
+
takeExtensions("/directory/path.ext") ==".ext"
314
+
takeExtensions("file.tar.gz") ==".tar.gz
315
+
```
316
+
317
+
Parameters:
318
+
319
+
`filepath`
320
+
: path
321
+
322
+
Returns:
323
+
324
+
- String of all extensions.
325
+
326
+
This function wraps [System.FilePath.takeExtensions](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:takeExtensions).
This function wraps [System.FilePath.dropExtension](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:dropExtension).
348
+
349
+
#### has_extension
350
+
351
+
`has_extensions(filepath)`
352
+
353
+
Does the given filename have an extension?
354
+
355
+
```lua
356
+
hasExtension("/directory/path.ext") ==true
357
+
hasExtension("/directory/path") ==false
358
+
```
359
+
360
+
Parameters:
361
+
362
+
`filepath`
363
+
: path
364
+
365
+
Returns:
366
+
367
+
-`true` if `filepath` has an extension.
368
+
369
+
This function wraps [System.FilePath.hasExtension](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:hasExtension).
This function wraps [System.FilePath.splitDirectories](https://hackage.haskell.org/package/filepath-1.4.2.1/docs/System-FilePath-Posix.html#v:splitDirectories).
393
+
394
+
#### join_path
395
+
396
+
`join_path(filepath)`
397
+
398
+
Join path elements back together by the directory separator.
0 commit comments