/**
* File descriptor.
*/
- int fd;
+ struct GNUNET_DISK_FileHandle *fh;
};
{
fhc->callback (fhc->callback_cls, res);
GNUNET_free (fhc->filename);
- if (fhc->fd != -1)
- GNUNET_break (0 == CLOSE (fhc->fd));
+ if (!GNUNET_DISK_handle_invalid (fhc->fh))
+ GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fhc->fh));
GNUNET_free (fhc); /* also frees fhc->buffer */
}
delta = fhc->bsize;
if (fhc->fsize - fhc->offset < delta)
delta = fhc->fsize - fhc->offset;
- if (delta != READ (fhc->fd, fhc->buffer, delta))
+ if (delta != GNUNET_DISK_file_read (fhc->fh, fhc->buffer, delta))
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
"read", fhc->filename);
fhc->callback_cls = callback_cls;
fhc->buffer = (unsigned char *) &fhc[1];
fhc->filename = GNUNET_strdup (filename);
- fhc->fd = -1;
+ fhc->fh = NULL;
sha512_init (&fhc->hctx);
fhc->bsize = blocksize;
if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fhc->fsize, GNUNET_NO))
return;
}
fhc->run_on_shutdown = run_on_shutdown;
- fhc->fd = GNUNET_DISK_file_open (filename, O_RDONLY | O_LARGEFILE);
- if (fhc->fd == -1)
+ fhc->fh = GNUNET_DISK_file_open (filename,
+ GNUNET_DISK_OPEN_READ);
+ if (!fhc->fh)
{
file_hash_finish (fhc, NULL);
return;