- Author
- Devresse Adrien ( adrie.nosp@m.n.de.nosp@m.vress.nosp@m.e@ce.nosp@m.rn.ch )
This exemple show how to open and read a file ex : use case with LFC plugin : ./gfal_testread lfn:/grid/dteam/test_skywalker
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define BLKLEN 65536
main(int argc, char **argv)
{
int fd;
char ibuf[BLKLEN];
int rc;
if (argc != 2) {
fprintf (stderr, "usage: %s filename\n", argv[0]);
exit (1);
}
printf ("opening %s\n", argv[1]);
if ((fd =
gfal_open (argv[1], O_RDONLY, 0)) < 0) {
exit (1);
}
printf ("open successful, fd = %d (errno = %d)\n", fd, errno);
if ((rc =
gfal_read (fd, ibuf, BLKLEN)) < 0) {
exit (1);
}
printf ("read successful (errno = %d)\n", errno);
exit (1);
}
printf ("close successful\n");
exit (0);
}