From 7ff46cf8d88fef8117fed30040f327a1ae6d82c1 Mon Sep 17 00:00:00 2001 From: sezero Date: Mon, 12 Dec 2011 10:50:26 +0000 Subject: [PATCH] made unix Sys_mkdir() to print strerror in case of failure. made windows Sys_mkdir() to use windows api functions. git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@507 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/sys_sdl_unix.c | 9 ++++-- Quake/sys_sdl_win.c | 76 ++++++++++++++++++++++---------------------- 2 files changed, 45 insertions(+), 40 deletions(-) diff --git a/Quake/sys_sdl_unix.c b/Quake/sys_sdl_unix.c index 6c4486b2..f31f6210 100644 --- a/Quake/sys_sdl_unix.c +++ b/Quake/sys_sdl_unix.c @@ -147,8 +147,13 @@ void Sys_Init (void) void Sys_mkdir (const char *path) { int rc = mkdir (path, 0777); - if (rc != 0 && errno != EEXIST) - Sys_Error("Unable to create directory %s", path); + if (rc != 0 && errno == EEXIST) + rc = 0; + if (rc != 0) + { + rc = errno; + Sys_Error("Unable to create directory %s: %s", path, strerror(rc)); + } } static const char errortxt1[] = "\nERROR-OUT BEGIN\n\n"; diff --git a/Quake/sys_sdl_win.c b/Quake/sys_sdl_win.c index e01c4373..d69f284a 100644 --- a/Quake/sys_sdl_win.c +++ b/Quake/sys_sdl_win.c @@ -196,8 +196,9 @@ void Sys_Init (void) void Sys_mkdir (const char *path) { - int rc = _mkdir (path); - if (rc != 0 && errno != EEXIST) + if (CreateDirectory(path, NULL) != 0) + return; + if (GetLastError() != ERROR_ALREADY_EXISTS) Sys_Error("Unable to create directory %s", path); } @@ -279,23 +280,23 @@ double Sys_FloatTime (void) char *Sys_ConsoleInput (void) { static char con_text[256]; - static int textlen; + static int textlen; INPUT_RECORD recs[1024]; int ch; DWORD dummy, numread, numevents; if (!isDedicated) - return NULL; // no stdin necessary in graphical mode + return NULL; for ( ;; ) { - if (!GetNumberOfConsoleInputEvents (hinput, &numevents)) + if (GetNumberOfConsoleInputEvents(hinput, &numevents) == 0) Sys_Error ("Error getting # of console events"); if (numevents <= 0) break; - if (!ReadConsoleInput(hinput, recs, 1, &numread)) + if (ReadConsoleInput(hinput, recs, 1, &numread) == 0) Sys_Error ("Error reading console input"); if (numread != 1) @@ -303,43 +304,42 @@ char *Sys_ConsoleInput (void) if (recs[0].EventType == KEY_EVENT) { - if (!recs[0].Event.KeyEvent.bKeyDown) + if (recs[0].Event.KeyEvent.bKeyDown == FALSE) + { + ch = recs[0].Event.KeyEvent.uChar.AsciiChar; + + switch (ch) { - ch = recs[0].Event.KeyEvent.uChar.AsciiChar; + case '\r': + WriteFile(houtput, "\r\n", 2, &dummy, NULL); - switch (ch) + if (textlen != 0) { - case '\r': - WriteFile(houtput, "\r\n", 2, &dummy, NULL); - - if (textlen) - { - con_text[textlen] = 0; - textlen = 0; - return con_text; - } - - break; - - case '\b': - WriteFile(houtput, "\b \b", 3, &dummy, NULL); - if (textlen) - { - textlen--; - } - break; - - default: - if (ch >= ' ') - { - WriteFile(houtput, &ch, 1, &dummy, NULL); - con_text[textlen] = ch; - textlen = (textlen + 1) & 0xff; - } - - break; + con_text[textlen] = 0; + textlen = 0; + return con_text; } + + break; + + case '\b': + WriteFile(houtput, "\b \b", 3, &dummy, NULL); + if (textlen != 0) + textlen--; + + break; + + default: + if (ch >= ' ') + { + WriteFile(houtput, &ch, 1, &dummy, NULL); + con_text[textlen] = ch; + textlen = (textlen + 1) & 0xff; + } + + break; } + } } }