-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathIO.ark
More file actions
73 lines (65 loc) · 2.21 KB
/
IO.ark
File metadata and controls
73 lines (65 loc) · 2.21 KB
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
# @brief Write content to a file. Return nil
# @param filename path to the file to write to (will be overwritten if it exists)
# @param content can be any valid ArkScript value
# =begin
# (io:writeFile "hello.json" "{\"key\": 12}")
# =end
# @author https://github.com/SuperFola
(let writeFile (fun (_name _content) (builtin__io:writeFile _name _content)))
# @brief Append content to a file. Return nil
# @param filename path to the file to append to
# @param content can be any valid ArkScript value
# =begin
# (io:writeFile "hello.json" "{\"key\": 12}")
# =end
# @author https://github.com/SuperFola
(let appendToFile (fun (_name _content) (builtin__io:appendToFile _name _content)))
# @brief Read the content from a file as a String
# @param filename the path of the file to read
# =begin
# (io:readFile "hello.json")
# =end
# @author https://github.com/SuperFola
(let readFile (fun (_name) (builtin__io:readFile _name)))
# @brief Read the content from a file as a List of Strings
# @param filename the path of the file to read
# =begin
# (io:readLinesFile "hello.json")
# =end
# @author https://github.com/SuperFola
(let readLinesFile (fun (_name) (builtin__io:readLinesFile _name)))
# @brief Check if a file exists, return True or False
# @param filename the path of the file
# =begin
# (io:fileExists? "hello.json")
# =end
# @author https://github.com/SuperFola
(let fileExists? (fun (_name) (builtin__io:fileExists? _name)))
# @brief List files in a folder, as a List of String
# @param path A directory
# =begin
# (io:listFiles "/tmp/hello")
# =end
# @author https://github.com/SuperFola
(let listFiles (fun (_path) (builtin__io:listFiles _path)))
# @brief Check if a path represents a directory
# @param path A directory
# =begin
# (io:dir? "/tmp/hello")
# =end
# @author https://github.com/SuperFola
(let dir? (fun (_path) (builtin__io:dir? _path)))
# @brief Create a directory
# @param path A directory
# =begin
# (io:makeDir "/tmp/myDir")
# =end
# @author https://github.com/SuperFola
(let makeDir (fun (_path) (builtin__io:makeDir _path)))
# @brief Delete file
# @param filename path to file
# =begin
# (io:removeFile "/tmp/test.ark")
# =end
# @author https://github.com/SuperFola
(let removeFile (fun (_path) (builtin__io:removeFile _path)))