X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=fs.c;h=e39858a0ed9fd3619abc6c8aca8b51721f42f201;hp=8d73b1d0b8ae793aa8dfefad075c9013457298ec;hb=eb2a74f7e7968f99f6a9e01de838a900ebd6efe0;hpb=3b630ec5dcd5945e5e0227d6a8e97c86fa2713c5 diff --git a/fs.c b/fs.c index 8d73b1d..e39858a 100644 --- a/fs.c +++ b/fs.c @@ -53,7 +53,7 @@ ) { wprintf(L"Invalid parameter dectected %s:%d %s [%s]\n", file, line, function, expression); wprintf(L"Aborting ...\n"); - abort(); + exit(EXIT_FAILURE); } static void file_init() { @@ -165,11 +165,6 @@ int fs_file_seek(FILE *fp, long int off, int whence) { return fseek(fp, off, whence); } -int fs_file_putc(FILE *fp, int ch) { - /* Invokes file_exception on windows if fp is null */ - return fputc(ch, fp); -} - int fs_file_flush(FILE *fp) { /* Invokes file_exception on windows if fp is null */ return fflush(fp); @@ -238,7 +233,7 @@ int fs_file_getline(char **lineptr, size_t *n, FILE *stream) { if (!dir) return NULL; - strcpy(dir->dd_name, name); + strncpy(dir->dd_name, name, strlen(name)); return dir; } @@ -258,8 +253,8 @@ int fs_file_getline(char **lineptr, size_t *n, FILE *stream) { if (*dir->dd_name) { size_t n = strlen(dir->dd_name); if ((dirname = (char*)mem_a(n + 5) /* 4 + 1 */)) { - strcpy(dirname, dir->dd_name); - strcpy(dirname + n, "\\*.*"); /* 4 + 1 */ + strncpy(dirname, dir->dd_name, n); + strncpy(dirname + n, "\\*.*", 4); /* 4 + 1 */ } } else { if (!(dirname = util_strdup("\\*.*"))) @@ -303,7 +298,6 @@ int fs_file_getline(char **lineptr, size_t *n, FILE *stream) { #else # if !defined(__MINGW32__) # include /* mkdir */ -# include /* chdir */ int fs_dir_make(const char *path) { return mkdir(path, 0700); @@ -326,8 +320,4 @@ struct dirent *fs_dir_read(DIR *dir) { return readdir(dir); } -int fs_dir_change(const char *path) { - return chdir(path); -} - #endif /*! defined(_WIN32) && !defined(__MINGW32__) */