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
This commit is contained in:
sezero 2011-12-12 10:50:26 +00:00
parent 2503c74cb6
commit 7ff46cf8d8
2 changed files with 45 additions and 40 deletions

View File

@ -147,8 +147,13 @@ void Sys_Init (void)
void Sys_mkdir (const char *path) void Sys_mkdir (const char *path)
{ {
int rc = mkdir (path, 0777); int rc = mkdir (path, 0777);
if (rc != 0 && errno != EEXIST) if (rc != 0 && errno == EEXIST)
Sys_Error("Unable to create directory %s", path); 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"; static const char errortxt1[] = "\nERROR-OUT BEGIN\n\n";

View File

@ -196,8 +196,9 @@ void Sys_Init (void)
void Sys_mkdir (const char *path) void Sys_mkdir (const char *path)
{ {
int rc = _mkdir (path); if (CreateDirectory(path, NULL) != 0)
if (rc != 0 && errno != EEXIST) return;
if (GetLastError() != ERROR_ALREADY_EXISTS)
Sys_Error("Unable to create directory %s", path); Sys_Error("Unable to create directory %s", path);
} }
@ -285,17 +286,17 @@ char *Sys_ConsoleInput (void)
DWORD dummy, numread, numevents; DWORD dummy, numread, numevents;
if (!isDedicated) if (!isDedicated)
return NULL; // no stdin necessary in graphical mode return NULL;
for ( ;; ) for ( ;; )
{ {
if (!GetNumberOfConsoleInputEvents (hinput, &numevents)) if (GetNumberOfConsoleInputEvents(hinput, &numevents) == 0)
Sys_Error ("Error getting # of console events"); Sys_Error ("Error getting # of console events");
if (numevents <= 0) if (numevents <= 0)
break; break;
if (!ReadConsoleInput(hinput, recs, 1, &numread)) if (ReadConsoleInput(hinput, recs, 1, &numread) == 0)
Sys_Error ("Error reading console input"); Sys_Error ("Error reading console input");
if (numread != 1) if (numread != 1)
@ -303,7 +304,7 @@ char *Sys_ConsoleInput (void)
if (recs[0].EventType == KEY_EVENT) 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; ch = recs[0].Event.KeyEvent.uChar.AsciiChar;
@ -312,7 +313,7 @@ char *Sys_ConsoleInput (void)
case '\r': case '\r':
WriteFile(houtput, "\r\n", 2, &dummy, NULL); WriteFile(houtput, "\r\n", 2, &dummy, NULL);
if (textlen) if (textlen != 0)
{ {
con_text[textlen] = 0; con_text[textlen] = 0;
textlen = 0; textlen = 0;
@ -323,10 +324,9 @@ char *Sys_ConsoleInput (void)
case '\b': case '\b':
WriteFile(houtput, "\b \b", 3, &dummy, NULL); WriteFile(houtput, "\b \b", 3, &dummy, NULL);
if (textlen) if (textlen != 0)
{
textlen--; textlen--;
}
break; break;
default: default: