aboutsummaryrefslogtreecommitdiff
path: root/src/fileutils.h
blob: e243a893deef7ebdf31a47a06046e5405d258e05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef FILEUTILS_H
#define FILEUTILS_H

#include <stddef.h>
#include <time.h>

const char* get_home_dir();
/* Returns 0 on success */
int file_get_content(const char *filepath, char **data, long *size);
/* Returns 0 on success */
int file_get_last_modified_time(const char *path, time_t *last_modified);
/* Returns 0 on success (if the directories are created or if the directories already exists) */
int create_directory_recursive(char *path);
/* Returns 0 on success */
int remove_recursive(char *path);
/* Returns 0 if the file exists */
int file_exists(const char *path);
/* Returns 0 on success */
int create_lock_file(const char *path);

int file_overwrite(const char *filepath, const char *data, size_t size);
int file_overwrite_in_dir(const char *dir, const char *filename, const char *data, size_t size);
/* Returns the length of the new path (the length of @output) */
int path_join(char *output, const char **components, int num_components);

#endif