Advertising
- Something
- Tuesday, June 12th, 2007 at 6:35:52am MDT
- /* read_from_from:
- fd - file to read rom
- buffer - buffer to read into
- *length - maximum amount of data to read.
- On return *length becomes the amount of data actually read.
- Returns true if the file is finished, or error.
- false if there is still data to rbe read.
- */
- static bool read_from_from(int fd, char *buffer, size_t *length)
- {
- size_t ret, data_read = 0;
- while (*length > 0)
- {
- ret = read(fd, buffer, *length);
- if (ret < 0) /* error */
- {
- *length = 0;
- return true;
- }
- else if (ret == 0)
- {
- *length = data_read;
- return true; /* file finished */
- }
- else
- {
- data_read += ret;
- *length -= ret;
- }
- }
- *length = data_read;
- return false;
- }
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.