summaryrefslogtreecommitdiff
path: root/tnslc/copy.tnsl
blob: 0cc594e313605945a1d05e721ba805d062fd20e0 (plain)
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
/#
    Proof of concept that the language can copy any file.

    For testing with executibles to make sure that the language's current state
    would be able to produce one from data alone.

    Seems to work.
#/

/; main ({}{}uint8 args) [int]
    /; if (len args < 2)
        ;tnsl.io.println("Usage: copy [file to copy] [path to copy to]")
        ;return 1
    ;/

    ;tnsl.io.File in = tnsl.io.readFile(args{0})
    ;tnsl.io.File out = tnsl.io.writeFile(args{1})

    /; loop (int chk = in.read(); chk !< 0) [chk = in.read()]
        ;uint8 write = chk
        ;out.write(write)
    ;/

    ;tnsl.io.println("Copy complete.")

    ;in.close()
    ;out.close()

    ;return 0
;/