mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-03-10 20:11:42 +00:00
made unix Sys_mkdir() to print strerror in case of failure.
made windows Sys_mkdir() to use windows api functions. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@507 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
1363a0cced
commit
36b0f26220
2 changed files with 45 additions and 40 deletions
|
@ -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";
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,23 +280,23 @@ double Sys_FloatTime (void)
|
||||||
char *Sys_ConsoleInput (void)
|
char *Sys_ConsoleInput (void)
|
||||||
{
|
{
|
||||||
static char con_text[256];
|
static char con_text[256];
|
||||||
static int textlen;
|
static int textlen;
|
||||||
INPUT_RECORD recs[1024];
|
INPUT_RECORD recs[1024];
|
||||||
int ch;
|
int ch;
|
||||||
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,43 +304,42 @@ 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;
|
||||||
|
|
||||||
|
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':
|
con_text[textlen] = 0;
|
||||||
WriteFile(houtput, "\r\n", 2, &dummy, NULL);
|
textlen = 0;
|
||||||
|
return con_text;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue