vfs_util.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2021 ML!PA Consulting GmbH
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
19 #include <stdbool.h>
20 #include <stddef.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
37 int vfs_file_from_buffer(const char *file, const void *buf, size_t len);
38 
51 int vfs_file_to_buffer(const char* file, void* buf, size_t len);
52 
53 #if MODULE_HASHES || DOXYGEN
67 int vfs_file_md5(const char* file, void *digest,
68  void *work_buf, size_t work_buf_len);
69 
83 int vfs_file_sha1(const char* file, void *digest,
84  void *work_buf, size_t work_buf_len);
85 
99 int vfs_file_sha256(const char* file, void *digest,
100  void *work_buf, size_t work_buf_len);
101 #endif
102 
115 int vfs_is_dir(const char *path);
116 
124 bool vfs_file_exists(const char *path);
125 
137 int vfs_unlink_recursive(const char *root, char *path_buf, size_t max_size);
138 
139 #ifdef __cplusplus
140 }
141 #endif
142 
int vfs_is_dir(const char *path)
Checks if path is a file or a directory.
int vfs_file_sha1(const char *file, void *digest, void *work_buf, size_t work_buf_len)
Compute the SHA1 message digest of a file.
int vfs_file_from_buffer(const char *file, const void *buf, size_t len)
Writes the content of a buffer to a file If the file already exists, it will be overwritten.
bool vfs_file_exists(const char *path)
Checks if path is a file and can be read.
int vfs_file_to_buffer(const char *file, void *buf, size_t len)
Reads the content of a file to a buffer.
int vfs_file_sha256(const char *file, void *digest, void *work_buf, size_t work_buf_len)
Compute the SHA256 message digest of a file.
int vfs_unlink_recursive(const char *root, char *path_buf, size_t max_size)
Behaves like rm -r @p root.
int vfs_file_md5(const char *file, void *digest, void *work_buf, size_t work_buf_len)
Compute the MD5 message digest of a file.