mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-18 14:21:36 +00:00
util_fopen...
This commit is contained in:
parent
2c020837ea
commit
0d9435d326
6 changed files with 18 additions and 7 deletions
2
code.c
2
code.c
|
@ -203,7 +203,7 @@ bool code_write(const char *filename) {
|
|||
util_endianswap(code_functions_data, code_functions_elements, sizeof(prog_section_function));
|
||||
util_endianswap(code_globals_data, code_globals_elements, sizeof(int32_t));
|
||||
|
||||
fp = fopen(filename, "wb");
|
||||
fp = util_fopen(filename, "wb");
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
|
|
2
exec.c
2
exec.c
|
@ -55,7 +55,7 @@ qc_program* prog_load(const char *filename)
|
|||
size_t i;
|
||||
FILE *file;
|
||||
|
||||
file = fopen(filename, "rb");
|
||||
file = util_fopen(filename, "rb");
|
||||
if (!file)
|
||||
return NULL;
|
||||
|
||||
|
|
4
gmqcc.h
4
gmqcc.h
|
@ -189,9 +189,7 @@ typedef char intptr_size_is_correct [sizeof(uintptr_t)== sizeof(int*)?1:-1];
|
|||
/*===================================================================*/
|
||||
/*=========================== util.c ================================*/
|
||||
/*===================================================================*/
|
||||
#ifdef WIN32
|
||||
# define fopen fopen_s
|
||||
#endif
|
||||
FILE *util_fopen(const char *filename, const char *mode);
|
||||
|
||||
void *util_memory_a (unsigned int, unsigned int, const char *);
|
||||
void util_memory_d (void *, unsigned int, const char *);
|
||||
|
|
2
lexer.c
2
lexer.c
|
@ -122,7 +122,7 @@ token* token_copy_all(const token *cp)
|
|||
lex_file* lex_open(const char *file)
|
||||
{
|
||||
lex_file *lex;
|
||||
FILE *in = fopen(file, "rb");
|
||||
FILE *in = util_fopen(file, "rb");
|
||||
|
||||
if (!in) {
|
||||
lexerror(NULL, "open failed: '%s'\n", file);
|
||||
|
|
2
main.c
2
main.c
|
@ -418,7 +418,7 @@ int main(int argc, char **argv) {
|
|||
char *line;
|
||||
|
||||
printf("Mode: progs.src\n");
|
||||
src = fopen("progs.src", "rb");
|
||||
src = util_fopen("progs.src", "rb");
|
||||
if (!src) {
|
||||
printf("failed to open `progs.src` for reading\n");
|
||||
retval = 1;
|
||||
|
|
13
util.c
13
util.c
|
@ -398,3 +398,16 @@ size_t util_strtononcmd(const char *in, char *out, size_t outsz) {
|
|||
*out = 0;
|
||||
return sz-1;
|
||||
}
|
||||
|
||||
FILE *util_fopen(const char *filename, const char *mode)
|
||||
{
|
||||
#ifdef WIN32
|
||||
FILE *out;
|
||||
if (fopen_s(&out, file, mode) != 0)
|
||||
return NULL;
|
||||
return out;
|
||||
#else
|
||||
return fopen(file, mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue