9 |
|
#include <stdlib.h> |
10 |
|
#include <string.h> |
11 |
|
#include <fcntl.h> |
12 |
+ |
#include "rtio.h" |
13 |
|
#include "platform.h" |
14 |
|
#include "resolu.h" |
15 |
|
#include "paths.h" |
134 |
|
} |
135 |
|
for (i = 0; i < rm->nrows; i++) |
136 |
|
for (j = 0; j < rm->ncols; j++) { |
137 |
< |
if (fread(val, sizeof(val[0]), rm->ncomp, fp) != rm->ncomp) |
137 |
> |
if (getbinary(val, sizeof(val[0]), rm->ncomp, fp) != rm->ncomp) |
138 |
|
return(0); |
139 |
|
for (k = rm->ncomp; k--; ) |
140 |
|
rmx_lval(rm,i,j,k) = val[k]; |
154 |
|
} |
155 |
|
for (i = 0; i < rm->nrows; i++) |
156 |
|
for (j = 0; j < rm->ncols; j++) { |
157 |
< |
if (fread(val, sizeof(val[0]), rm->ncomp, fp) != rm->ncomp) |
157 |
> |
if (getbinary(val, sizeof(val[0]), rm->ncomp, fp) != rm->ncomp) |
158 |
|
return(0); |
159 |
|
for (k = rm->ncomp; k--; ) |
160 |
|
rmx_lval(rm,i,j,k) = val[k]; |
195 |
|
|
196 |
|
if (inspec == NULL) { /* reading from stdin? */ |
197 |
|
inspec = "<stdin>"; |
198 |
< |
#if defined(_WIN32) || defined(_WIN64) |
198 |
< |
_setmode(fileno(stdin), _O_BINARY); |
199 |
< |
#endif |
198 |
> |
SET_FILE_BINARY(stdin); |
199 |
|
} else if (inspec[0] == '!') { |
200 |
|
if ((fp = popen(inspec+1, "r")) == NULL) |
201 |
|
return(NULL); |
202 |
< |
#if defined(_WIN32) || defined(_WIN64) |
204 |
< |
_setmode(fileno(fp), _O_BINARY); |
205 |
< |
#endif |
202 |
> |
SET_FILE_BINARY(stdin); |
203 |
|
} else { |
204 |
|
const char *sp = inspec; /* check suffix */ |
205 |
|
while (*sp) |
250 |
|
dnew->info = dinfo.info; |
251 |
|
switch (dinfo.dtype) { |
252 |
|
case DTascii: |
253 |
< |
#if defined(_WIN32) || defined(_WIN64) |
257 |
< |
_setmode(fileno(fp), _O_TEXT); |
258 |
< |
#endif |
253 |
> |
SET_FILE_TEXT(stdin); |
254 |
|
if (!rmx_load_ascii(dnew, fp)) |
255 |
|
goto loaderr; |
256 |
|
dnew->dtype = DTascii; /* should leave double? */ |
324 |
|
for (j = 0; j < rm->ncols; j++) { |
325 |
|
for (k = rm->ncomp; k--; ) |
326 |
|
val[k] = (float)rmx_lval(rm,i,j,k); |
327 |
< |
if (fwrite(val, sizeof(val[0]), rm->ncomp, fp) != rm->ncomp) |
327 |
> |
if (putbinary(val, sizeof(val[0]), rm->ncomp, fp) != rm->ncomp) |
328 |
|
return(0); |
329 |
|
} |
330 |
|
return(1); |
344 |
|
for (j = 0; j < rm->ncols; j++) { |
345 |
|
for (k = rm->ncomp; k--; ) |
346 |
|
val[k] = rmx_lval(rm,i,j,k); |
347 |
< |
if (fwrite(val, sizeof(val[0]), rm->ncomp, fp) != rm->ncomp) |
347 |
> |
if (putbinary(val, sizeof(val[0]), rm->ncomp, fp) != rm->ncomp) |
348 |
|
return(0); |
349 |
|
} |
350 |
|
return(1); |