1.1 --- a/libfsclient/lib/src/file.cc Tue Jan 04 23:27:53 2022 +0100
1.2 +++ b/libfsclient/lib/src/file.cc Tue Jan 04 23:43:56 2022 +0100
1.3 @@ -137,6 +137,30 @@
1.4 return err;
1.5 }
1.6
1.7 +/* Remove a file from the filesystem. This is a convenience function invoking
1.8 + file_context and file_context_remove. */
1.9 +
1.10 +long file_remove(const char *filename, l4_cap_idx_t server)
1.11 +{
1.12 + file_t context;
1.13 + long err;
1.14 +
1.15 + err = file_context(&context, server);
1.16 + if (err)
1.17 + return err;
1.18 +
1.19 + if (!file_string_set(&context, filename, 0, NULL))
1.20 + return -L4_ENOMEM;
1.21 +
1.22 + err = file_context_remove(&context);
1.23 +
1.24 + /* Close the context, although a separate mechanism could permit contexts to
1.25 + open several files. */
1.26 +
1.27 + file_close(&context);
1.28 + return err;
1.29 +}
1.30 +
1.31
1.32
1.33 /* Initialise a file structure for a context obtained from the given server
1.34 @@ -179,6 +203,14 @@
1.35 return openercontext.open(flags, &file->size, &file->ref, &file->object_flags);
1.36 }
1.37
1.38 +/* Remove a file using the given context. */
1.39 +
1.40 +long file_context_remove(file_t *context)
1.41 +{
1.42 + client_OpenerContext openercontext(context->ref);
1.43 + return openercontext.remove();
1.44 +}
1.45 +
1.46
1.47
1.48 /* Flush populated data and obtain an updated file size and populated data