File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 109
109
(var-cast-to out-buffer (* char) (malloc file-size))
110
110
(fread out-buffer file-size 1 in-file)
111
111
(return out-buffer))
112
+
113
+ (defun write-string (out-file (* FILE) out-string (* (const char)))
114
+ (var string-length size_t (strlen out-string))
115
+ ;; (fprintf stderr " % s has length % d\ n" out-string (type-cast string-length int))
116
+ (fwrite (addr string-length) (sizeof string-length) 1 out-file)
117
+ (fwrite out-string string-length 1 out-file))
118
+
119
+ (defun read-string (in-file (* FILE) out-string-buffer (* char) out-string-buffer-length size_t)
120
+ (var string-length size_t 0)
121
+ (fread (addr string-length) (sizeof string-length) 1 in-file)
122
+ ;; (fprintf stderr " Next string has length % d\ n" (type-cast string-length int))
123
+ (assert (<= string-length out-string-buffer-length))
124
+ (fread out-string-buffer string-length 1 in-file))
125
+
126
+ ;; Plain old data with a known size
127
+ (defmacro write-pod (item any out-file any)
128
+ (tokenize-push output
129
+ (fwrite (addr (token-splice item)) (sizeof (token-splice item)) 1 (token-splice out-file)))
130
+ (return true))
131
+
132
+ (defmacro read-pod (item any in-file any)
133
+ (tokenize-push output
134
+ (fread (addr (token-splice item)) (sizeof (token-splice item)) 1 (token-splice in-file)))
135
+ (return true))
You can’t perform that action at this time.
0 commit comments