2020-06-16 21:39:45 +00:00
|
|
|
#include "webfuse_provider/impl/dirbuffer.h"
|
2019-03-03 12:34:43 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2019-03-26 22:04:53 +00:00
|
|
|
struct wfp_dirbuffer * wfp_impl_dirbuffer_create(void)
|
2019-03-03 12:34:43 +00:00
|
|
|
{
|
2019-03-26 22:04:53 +00:00
|
|
|
struct wfp_dirbuffer * buffer = malloc(sizeof(struct wfp_dirbuffer));
|
2020-03-21 20:22:22 +00:00
|
|
|
buffer->entries = json_array();
|
2019-03-03 12:34:43 +00:00
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2019-03-26 22:04:53 +00:00
|
|
|
void wfp_impl_dirbuffer_dispose(
|
|
|
|
struct wfp_dirbuffer * buffer)
|
2019-03-03 12:34:43 +00:00
|
|
|
{
|
|
|
|
if (NULL != buffer->entries)
|
|
|
|
{
|
|
|
|
json_decref(buffer->entries);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(buffer);
|
|
|
|
}
|
|
|
|
|
2019-03-26 22:04:53 +00:00
|
|
|
void wfp_impl_dirbuffer_add(
|
|
|
|
struct wfp_dirbuffer * buffer,
|
2019-03-03 12:34:43 +00:00
|
|
|
char const * name,
|
|
|
|
ino_t inode)
|
|
|
|
{
|
|
|
|
json_t * entry = json_object();
|
|
|
|
json_object_set_new(entry, "name", json_string(name));
|
|
|
|
json_object_set_new(entry, "inode", json_integer(inode));
|
|
|
|
|
2019-03-03 14:15:55 +00:00
|
|
|
json_array_append_new(buffer->entries, entry);
|
2019-03-03 12:34:43 +00:00
|
|
|
}
|
|
|
|
|
2019-03-26 22:04:53 +00:00
|
|
|
json_t * wfp_impl_dirbuffer_take(
|
|
|
|
struct wfp_dirbuffer * buffer)
|
2019-03-03 12:34:43 +00:00
|
|
|
{
|
|
|
|
json_t * entries = buffer->entries;
|
|
|
|
|
|
|
|
buffer->entries = NULL;
|
|
|
|
return entries;
|
|
|
|
}
|