[chocolate-doom] 79/83: Remove non-ANSI C headers and functions
Jonathan Dowland
jmtd at moszumanska.debian.org
Mon Jan 30 15:06:28 UTC 2017
This is an automated email from the git hooks/post-receive script.
jmtd pushed a commit to annotated tag chocolate-doom-0.0.1
in repository chocolate-doom.
commit 3bbed813e4ee72bd7fcf974e17835ab07c2b74b4
Author: Simon Howard <fraggle at gmail.com>
Date: Wed Sep 7 21:40:11 2005 +0000
Remove non-ANSI C headers and functions
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 85
---
src/m_misc.c | 79 +++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 46 insertions(+), 33 deletions(-)
diff --git a/src/m_misc.c b/src/m_misc.c
index 4957f6a..92ecc39 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: m_misc.c 82 2005-09-07 12:34:47Z fraggle $
+// $Id: m_misc.c 85 2005-09-07 21:40:11Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -23,6 +23,9 @@
//
//
// $Log$
+// Revision 1.8 2005/09/07 21:40:11 fraggle
+// Remove non-ANSI C headers and functions
+//
// Revision 1.7 2005/09/07 12:34:47 fraggle
// Maintain dos-specific options in config file
//
@@ -57,14 +60,10 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: m_misc.c 82 2005-09-07 12:34:47Z fraggle $";
+rcsid[] = "$Id: m_misc.c 85 2005-09-07 21:40:11Z fraggle $";
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
+#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
-
#include <ctype.h>
@@ -141,22 +140,18 @@ M_DrawText
#define O_BINARY 0
#endif
-boolean
-M_WriteFile
-( char const* name,
- void* source,
- int length )
+boolean M_WriteFile(char const *name, void *source, int length)
{
- int handle;
- int count;
+ FILE *handle;
+ int count;
- handle = open ( name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
+ handle = fopen(name, "wb");
- if (handle == -1)
+ if (handle == NULL)
return false;
- count = write (handle, source, length);
- close (handle);
+ count = fwrite(source, 1, length, handle);
+ fclose(handle);
if (count < length)
return false;
@@ -168,24 +163,26 @@ M_WriteFile
//
// M_ReadFile
//
-int
-M_ReadFile
-( char const* name,
- byte** buffer )
+int M_ReadFile(char const *name, byte **buffer)
{
- int handle, count, length;
- struct stat fileinfo;
- byte *buf;
+ FILE *handle;
+ int count, length;
+ byte *buf;
- handle = open (name, O_RDONLY | O_BINARY, 0666);
- if (handle == -1)
- I_Error ("Couldn't read file %s", name);
- if (fstat (handle,&fileinfo) == -1)
+ handle = fopen(name, "rb");
+ if (handle == NULL)
I_Error ("Couldn't read file %s", name);
- length = fileinfo.st_size;
+
+ // find the size of the file by seeking to the end and
+ // reading the current position
+
+ fseek(handle, 0, SEEK_END);
+ length = ftell(handle);
+ fseek(handle, 0, SEEK_SET);
+
buf = Z_Malloc (length, PU_STATIC, NULL);
- count = read (handle, buf, length);
- close (handle);
+ count = fread(buf, 1, length, handle);
+ fclose (handle);
if (count < length)
I_Error ("Couldn't read file %s", name);
@@ -578,6 +575,22 @@ WritePCXfile
Z_Free (pcx);
}
+static boolean FileExists(char *filename)
+{
+ FILE *handle;
+
+ handle = fopen(filename, "rb");
+
+ if (handle != NULL)
+ {
+ fclose(handle);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
//
// M_ScreenShot
@@ -599,7 +612,7 @@ void M_ScreenShot (void)
{
lbmname[4] = i/10 + '0';
lbmname[5] = i%10 + '0';
- if (access(lbmname,0) == -1)
+ if (!FileExists(lbmname))
break; // file doesn't exist
}
if (i==100)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/chocolate-doom.git
More information about the Pkg-games-commits
mailing list