|
898 | 898 | (mac reading (var port . body)
|
899 | 899 | `(ifread ,var ,port (do ,@body)))
|
900 | 900 |
|
901 |
| -; inconsistency between names of readfile[1] and writefile |
| 901 | +(mac fromfile (f . body) |
| 902 | + (w/uniq gf |
| 903 | + `(w/infile ,gf ,f |
| 904 | + (w/stdin ,gf |
| 905 | + ,@body)))) |
| 906 | + |
| 907 | +(mac tofile (f . body) |
| 908 | + (w/uniq (gf gs) |
| 909 | + `(let ,gs (+ ,f "." rand-string.6) |
| 910 | + (w/outfile ,gf ,gs |
| 911 | + (w/stdout ,gf |
| 912 | + ,@body)) |
| 913 | + (mvfile ,gs ,f)))) |
| 914 | + |
| 915 | +(mac ontofile (f . body) |
| 916 | + (w/uniq gf |
| 917 | + `(w/appendfile ,gf ,f |
| 918 | + (w/stdout ,gf |
| 919 | + ,@body)))) |
902 | 920 |
|
903 |
| -(def readfile (name) (w/infile s name (drain:read s))) |
| 921 | +(def readfile (name) |
| 922 | + (fromfile name |
| 923 | + (drain:read))) |
904 | 924 |
|
905 |
| -(def readfile1 (name) (w/infile s name (read s))) |
| 925 | +(def readfile1 (name) |
| 926 | + (fromfile name |
| 927 | + (read))) |
| 928 | + |
| 929 | +(def writefile (val name) |
| 930 | + (tofile name |
| 931 | + (write val))) |
906 | 932 |
|
907 | 933 | (def readall (src (o eof nil))
|
908 | 934 | ((afn (i)
|
|
919 | 945 | (def filechars (name)
|
920 | 946 | (w/infile s name (allchars s)))
|
921 | 947 |
|
922 |
| -(def writefile (val file) |
923 |
| - (let tmpfile (+ file ".tmp") |
924 |
| - (w/outfile o tmpfile (write val o)) |
925 |
| - (mvfile tmpfile file)) |
926 |
| - val) |
927 |
| - |
928 | 948 | (= ac-denil ($ ac-denil))
|
929 | 949 | (= ac-global-name ($ ac-global-name))
|
930 | 950 | (= ac-niltree ($ ac-niltree))
|
|
1925 | 1945 | ,within)
|
1926 | 1946 | ,@body))))
|
1927 | 1947 |
|
1928 |
| -(mac tofile (name . body) |
1929 |
| - (w/uniq str `(w/outfile ,str ,name (w/stdout ,str ,@body)))) |
1930 |
| - |
1931 |
| -(mac ontofile (name . body) |
1932 |
| - (w/uniq str `(w/appendfile ,str ,name (w/stdout ,str ,@body)))) |
1933 |
| - |
1934 |
| -(mac fromfile (name . body) |
1935 |
| - (w/uniq str `(w/infile ,str ,name (w/stdin ,str ,@body)))) |
1936 |
| - |
1937 | 1948 | (def cars (xs) (map car xs))
|
1938 | 1949 | (def cdrs (xs) (map cdr xs))
|
1939 | 1950 |
|
|
0 commit comments