- Con_Printf("Sys_FileOpenWrite: Error opening %s: %s", path, strerror(errno));
- return 0;
- }
-
- return handle;
-}
-
-int Sys_FileWrite (int handle, void *src, int count)
-{
- return write (handle, src, count);
-}
-
-void Sys_FileClose (int handle)
-{
- close (handle);
-}
-
-void Sys_FileSeek (int handle, int position)
-{
- lseek (handle, position, SEEK_SET);
-}
-
-int Sys_FileRead (int handle, void *dest, int count)
-{
- return read (handle, dest, count);
-}
-
-void Sys_DebugLog(char *file, char *fmt, ...)
-{
- va_list argptr;
- static char data[1024];
- int fd;
-
- va_start(argptr, fmt);
- vsprintf(data, fmt, argptr);
- va_end(argptr);
- fd = open(file, O_WRONLY | O_CREAT | O_APPEND, 0666);
- write(fd, data, strlen(data));
- close(fd);
-}
-
-double Sys_DoubleTime (void)
-{
- static int first = true;
- static double oldtime = 0.0, curtime = 0.0;
- double newtime;
- struct timeval tp;
-
- gettimeofday(&tp, NULL);
-
- newtime = (double) tp.tv_sec + tp.tv_usec / 1000000.0;
-
- if (first)
- {
- first = false;
- oldtime = newtime;
- }
-
- if (newtime < oldtime)
- {
- if (newtime < oldtime - 0.001)
- Con_Printf("Sys_DoubleTime: time stepped backwards (went from %f to %f, difference %f)\n", oldtime, newtime, newtime - oldtime);
+ int origflags = fcntl (sys.outfd, F_GETFL, 0);
+ fcntl (sys.outfd, F_SETFL, origflags & ~FNDELAY);
+#endif
+#ifdef WIN32
+#define write _write
+#endif
+ while(*text)
+ {
+ fs_offset_t written = (fs_offset_t)write(sys.outfd, text, (int)strlen(text));
+ if(written <= 0)
+ break; // sorry, I cannot do anything about this error - without an output
+ text += written;
+ }
+#ifdef FNDELAY
+ fcntl (sys.outfd, F_SETFL, origflags);