File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ include "cores/select.cal"
2
+ include "std/io.cal"
3
+ include "std/args.cal"
4
+
5
+ if get_args_length 2 < then
6
+ "Required parameter: path\n" printstr
7
+ 0 exit
8
+ end
9
+
10
+ let Array path
11
+ 1 path get_arg
12
+
13
+ let File file
14
+ path FILE_READ open_file file file<
15
+
16
+ if file @ -2 = then
17
+ "Failed to open file\n" printstr
18
+ 1 exit
19
+ end
20
+
21
+ let cell fileSize
22
+ let array 16384 u8 fileContents
23
+
24
+ file 0 SEEK_END file_seek
25
+ file file_peek fileSize !
26
+ file 0 SEEK_SET file_seek
27
+
28
+ let Array fileArray
29
+ fileContents fileArray Array.elements + !
30
+ 1 fileArray Array.memberSize + !
31
+ fileSize @ fileArray Array.length + !
32
+
33
+ file fileContents fileSize @ file@
34
+
35
+ fileArray printstr new_line
Original file line number Diff line number Diff line change
1
+ include "cores/select.cal"
2
+ include "std/io.cal"
3
+
4
+ let File file
5
+ "test" FILE_WRITE open_file file file<
6
+
7
+ if file @ -2 = then
8
+ "Failed to open file\n" printstr
9
+ 1 exit
10
+ end
11
+
12
+ let Array str
13
+ "meow\n" str a<
14
+
15
+ file
16
+ str Array.elements + @
17
+ str Array.length + @ file!
You can’t perform that action at this time.
0 commit comments