FreeCalypso > hg > freecalypso-tools
comparison rvinterf/etmsync/fswrite.c @ 306:8136fb5eb292
fc-fsio: write_buf_to_file() function made global in prep for upload-rf-table
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 21 Nov 2017 06:09:35 +0000 |
parents | e7502631a0f9 |
children | a0754c98fc2b |
comparison
equal
deleted
inserted
replaced
305:3d79116be312 | 306:8136fb5eb292 |
---|---|
159 "error: middle argument to fwrite cmd must be \"ascii\", \"hex\" or \"file\"\n" | 159 "error: middle argument to fwrite cmd must be \"ascii\", \"hex\" or \"file\"\n" |
160 ); | 160 ); |
161 return(ERROR_USAGE); | 161 return(ERROR_USAGE); |
162 } | 162 } |
163 } | 163 } |
164 | |
165 write_buf_to_file(pathname, data, datalen) | |
166 char *pathname; | |
167 u_char *data; | |
168 { | |
169 int tfd, rc, chunk, remain; | |
170 | |
171 if (datalen <= max_short_file_write(pathname)) | |
172 return do_short_fwrite(pathname, data, datalen); | |
173 /* do it the long way */ | |
174 rc = fd_open(pathname, FFS_O_WRONLY | FFS_O_CREATE | FFS_O_TRUNC, &tfd); | |
175 if (rc) | |
176 return(rc); | |
177 for (remain = datalen; remain; remain -= chunk) { | |
178 chunk = remain; | |
179 if (chunk > 240) | |
180 chunk = 240; | |
181 rc = fd_write(tfd, data, chunk); | |
182 if (rc) { | |
183 fd_close(tfd); | |
184 return(rc); | |
185 } | |
186 data += chunk; | |
187 } | |
188 return fd_close(tfd); | |
189 } |