diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2022-07-26 18:30:00 -0300 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2022-07-26 18:30:31 -0300 |
commit | 9edc129c0d675b80aee9d2f382bd80ed9a43ddba (patch) | |
tree | 2348753f0ce97eb585987e909356d4e4c2485f3a /git.c | |
parent | 60780c0aa29706cd323a69b495362cc633a0c4e5 (diff) |
git: Add `create_file()`
Diffstat (limited to 'git.c')
-rw-r--r-- | git.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -64,6 +64,17 @@ void cleanup_git(git_repository **repos) { git_libgit2_shutdown(); } +file *create_file(const char *root, const char *filename) { + const size_t path_len = format_len("%s/%s", root, filename); + char *path = calloc(path_len+1, sizeof(char)); + long buf_size = 0; + file *f = calloc(1, sizeof(file)); + sprintf(path, "%s/%s", root, filename); + f->name = (char *)filename; + f->buf = read_file(filename, &buf_size); + return f; +} + void free_file(file *file) { if (file->name != NULL) { free(file->name); |