libgpio
|
File Helper Library API. More...
#include <unistd.h>
#include <stdbool.h>
Go to the source code of this file.
Functions | |
int | file_get_size (char *filename, off_t *size) |
Get size of file in bytes. More... | |
bool | file_is_present (char *filename) |
Determine if file is present (i.e., exists) More... | |
int | file_read (int fd, void *buf, size_t len) |
Read specified number of bytes from file or socket. More... | |
int | file_write (int fd, void *buf, size_t len) |
Write specified number of bytes to file or socket. More... | |
int | file_owc (char *filename, void *buf, size_t len) |
Open, write to, and close a file. More... | |
File Helper Library API.
int file_get_size | ( | char * | filename, |
off_t * | size | ||
) |
Get size of file in bytes.
[in] | filename | Pointer to filename string |
[out] | size | Pointer to where file size is placed |
bool file_is_present | ( | char * | filename | ) |
Determine if file is present (i.e., exists)
[in] | filename | Pointer to filename string |
int file_owc | ( | char * | filename, |
void * | buf, | ||
size_t | len | ||
) |
Open, write to, and close a file.
[in] | filename | Pointer to filename string |
[in] | buf | Buffer containing data to write |
[in] | len | Number of bytes to write |
Open the specified file, write the specified number of bytes, and close the file. It may block indefinitely as described by the file_write() documentation.
int file_read | ( | int | fd, |
void * | buf, | ||
size_t | len | ||
) |
Read specified number of bytes from file or socket.
[in] | fd | File descriptor to read from |
[out] | buf | Buffer to place incoming data |
[in] | len | Number of bytes to read |
Read the specified number of bytes from the file/pipe/socket associated with the passed in file descriptor. It will block waiting indefinitely for the specified number of bytes to be received or until it is interrupted. If the read() system call returns with a return code of zero, -ECONNRESET will be returned.
int file_write | ( | int | fd, |
void * | buf, | ||
size_t | len | ||
) |
Write specified number of bytes to file or socket.
[in] | fd | File descriptor to write to |
[in] | buf | Buffer containing data to write |
[in] | len | Number of bytes to write |
Write the specified number of bytes to the file/pipe/socket associated with the passed in file descriptor. It will block indefinitely until the specified number of bytes have been accepted by the kernel or until it is interrupted.