summaryrefslogtreecommitdiff
path: root/windows/cache.c
blob: a7dd81ef7d0703a341dcb6165dbf0c8cc7a39403 (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
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>

#include "../include/cache.h"
#include "../include/read_cfg.h"

char *get_cache_path(bool create){
	char *path = malloc(sizeof(char) * BUF_LEN);
	char *appdata = getenv("APPDATA");

	if(appdata == NULL){
		printf("Failed to save cache data: APPDATA is not set\n");
		free(path);
		return NULL;
	}

	//if create is asserted, build the path to the file
	if(create){
		sprintf(path, "%s%ctml%c", appdata, sep, sep);
		mkdir(path);
	}

	sprintf(path, "%s%ctml%ccache.bin", appdata, sep, sep);

	return path;
}