aboutsummaryrefslogtreecommitdiff
path: root/analyzer/utils/fs.c
blob: e6d32564256176afc88bc9ca7969d853469a7c7d (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
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "utils/fs.h"

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>

void get_home_dir(char *home_dir) {
    strcpy(home_dir, getenv("HOME"));
}

void get_main_dir(char *main_dir) {
    char home_dir[PATH_MAX];
    get_home_dir(home_dir);
    sprintf(main_dir, "%s/.local/share/branal", home_dir);
}

void get_capture_dir(char *capture_dir) {
    char main_dir[PATH_MAX];
    get_main_dir(main_dir);
    sprintf(capture_dir, "%s/captures", main_dir);
}

void get_saves_dir(char *saves_dir) {
    char main_dir[PATH_MAX];
    get_main_dir(main_dir);
    sprintf(saves_dir, "%s/saves", main_dir);
}

void create_necessary_directories() {
    char main_dir[PATH_MAX], capture_dir[PATH_MAX], saves_dir[PATH_MAX];
    get_main_dir(main_dir);
    get_capture_dir(capture_dir);
    get_saves_dir(saves_dir);
    mkdir(main_dir, 0755);
    mkdir(capture_dir, 0755);
    mkdir(saves_dir, 0755);
}