mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-07 18:58:01 +02:00
Add new ply_buffer_append_from_fd function
This function just reads a chunk of bytes from and fd and adds the bytes to the buffer.
This commit is contained in:
parent
05dd704985
commit
49aada170b
2 changed files with 23 additions and 0 deletions
|
|
@ -192,6 +192,26 @@ ply_buffer_append_bytes (ply_buffer_t *buffer,
|
|||
buffer->size += length;
|
||||
}
|
||||
|
||||
void
|
||||
ply_buffer_append_from_fd (ply_buffer_t *buffer,
|
||||
int fd)
|
||||
{
|
||||
|
||||
char bytes[PLY_BUFFER_MAX_APPEND_SIZE] = "";
|
||||
ssize_t bytes_read;
|
||||
|
||||
assert (buffer != NULL);
|
||||
assert (fd >= 0);
|
||||
|
||||
if (!ply_fd_has_data (fd))
|
||||
return;
|
||||
|
||||
bytes_read = read (fd, bytes, sizeof (bytes));
|
||||
|
||||
if (bytes_read > 0)
|
||||
ply_buffer_append_bytes (buffer, bytes, bytes_read);
|
||||
}
|
||||
|
||||
const char *
|
||||
ply_buffer_get_bytes (ply_buffer_t *buffer)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ void ply_buffer_free (ply_buffer_t *buffer);
|
|||
void ply_buffer_append_bytes (ply_buffer_t *buffer,
|
||||
const void *bytes,
|
||||
size_t number_of_bytes);
|
||||
|
||||
void ply_buffer_append_from_fd (ply_buffer_t *buffer,
|
||||
int fd);
|
||||
#define ply_buffer_append(buffer, format, args...) \
|
||||
ply_buffer_append_with_non_literal_format_string (buffer, \
|
||||
format "", ##args)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue