|
@@ -1,38 +1,36 @@
|
|
#include "fio.h"
|
|
#include "fio.h"
|
|
|
|
|
|
|
|
+#include "platform.h"
|
|
|
|
+
|
|
#include <assert.h>
|
|
#include <assert.h>
|
|
#include <inttypes.h>
|
|
#include <inttypes.h>
|
|
-#include <io.h>
|
|
|
|
|
|
+
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <string.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/stat.h>
|
|
|
|
+#include <errno.h>
|
|
|
|
|
|
void read_shader_source(GLchar *source, const char *file_path) {
|
|
void read_shader_source(GLchar *source, const char *file_path) {
|
|
|
|
|
|
GLchar buf[1024] = {0};
|
|
GLchar buf[1024] = {0};
|
|
- errno_t err = 0;
|
|
|
|
- struct _stat st;
|
|
|
|
|
|
+ struct stat st;
|
|
int result = 0;
|
|
int result = 0;
|
|
|
|
|
|
- if (_access(file_path, 4) == -1) {
|
|
|
|
|
|
+ if (ACCESS(file_path, 4) == -1) {
|
|
fprintf(stderr, "file not found %s\n", file_path);
|
|
fprintf(stderr, "file not found %s\n", file_path);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
FILE *f = NULL;
|
|
FILE *f = NULL;
|
|
|
|
|
|
- err = fopen_s(&f, file_path, "r");
|
|
|
|
- if (err != 0) {
|
|
|
|
- fprintf(stderr, "could not open file %s\n", file_path);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- result = _stat(file_path, &st);
|
|
|
|
|
|
+ f = FOPEN(file_path, "r");
|
|
|
|
+
|
|
|
|
+ result = STAT(file_path, &st);
|
|
assert(result == 0 && "could not stat file");
|
|
assert(result == 0 && "could not stat file");
|
|
assert(st.st_size <= 1024 && "shader source too long");
|
|
assert(st.st_size <= 1024 && "shader source too long");
|
|
|
|
|
|
fread(buf, st.st_size, 1, f);
|
|
fread(buf, st.st_size, 1, f);
|
|
assert(buf[0] != 0);
|
|
assert(buf[0] != 0);
|
|
|
|
|
|
- strcpy_s(source, 1024, buf);
|
|
|
|
-}
|
|
|
|
|
|
+ STRCPY(source, buf);
|
|
|
|
+}
|