From 070f39fc2b033bcf53797480c4b1ce27a0eb0f91 Mon Sep 17 00:00:00 2001 From: Mosder Date: Thu, 11 Jun 2026 17:26:52 +0200 Subject: feat: added utils/fs.h for filesystem operations and made a function to create necessary directories --- analyzer/utils/fs.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 analyzer/utils/fs.h (limited to 'analyzer/utils/fs.h') diff --git a/analyzer/utils/fs.h b/analyzer/utils/fs.h new file mode 100644 index 0000000..6335799 --- /dev/null +++ b/analyzer/utils/fs.h @@ -0,0 +1,31 @@ +// utils/fs.h +// functions for operating on the file system, i.e. creating directories, writing files, etc. + +#include + +// get main directory used by the program +// params: +// - main_dir - buffer to save the directory to +extern void get_main_dir(char *main_dir); + +// get directory to save the .pcap files to +// params: +// - capture_dir - buffer to save the directory to +extern void get_capture_dir(char *capture_dir); + +// get directory of save data of the program +// params: +// - saves_dir - buffer to save the directory to +extern void get_saves_dir(char *saves_dir); + +// create directories that will be used by the program +extern void create_necessary_directories(); + +// writes file to the specified path +// params: +// - path - path to write the file to +// - contents - contents of the file +// - contents_len - amount of bytes of contents to write +// - flags - flags to open the file with +// - permissions - permissions of the written file +extern void write_file(char *path, void *contents, int contents_len, int flags, mode_t permissions); -- cgit v1.2.3