aboutsummaryrefslogtreecommitdiff
path: root/sources/TZR_ResourcesWatch.c
blob: 80612f15530c6a0cced99b3262758f63c7c8818e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "TZR_resource.h"
#include "TZR_globals.h"
#include <sys/stat.h>

void TZR_ResourcesWatch(void)
{
	for (TZR_Uint i = 0; i < ___tzr_resources_size; i++) {
		TZR_Resource *const res = TZR_GetResourcePointer(i + 1);
		if (res->path == NULL)
			continue;
		struct stat st = {0};
		(void)stat(res->path, &st);
		if (st.st_mtime != res->mtime) {
			if (res->mtime != 0)
				TZR_ReloadResource(i + 1);
			res->mtime = st.st_mtime;
		}
	}
}