mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +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: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@507 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
2503c74cb6
commit
7ff46cf8d8
2 changed files with 45 additions and 40 deletions
|
@ -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";
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue