blob: 435d61273c5016e658524a0268d26fe4e7716965 (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <raylib.h>
#define FILENAME_INPUT "./res/spotlight.frag"
#define FILENAME_OUTPUT "./build/spotlight.frag.c"
int
main (int argc, char *argv[])
{
remove (FILENAME_OUTPUT);
int fd = open (FILENAME_INPUT, O_RDONLY);
if (fd == -1) {
perror ("open");
return EXIT_FAILURE;
}
struct stat sb;
if (fstat (fd, &sb) == -1) {
perror ("fstat");
close (fd);
return EXIT_FAILURE;
}
void *mapped = mmap (NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (mapped == MAP_FAILED) {
perror ("mmap");
close (fd);
return EXIT_FAILURE;
}
if (!ExportDataAsCode (mapped, sb.st_size, FILENAME_OUTPUT)) {
perror ("raylib");
close (fd);
return EXIT_FAILURE;
}
if (munmap (mapped, sb.st_size) == -1)
perror ("munmap");
close (fd);
if (chmod (FILENAME_OUTPUT, S_IRUSR | S_IRGRP | S_IROTH) == -1) {
perror ("chmod");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
|