1 /*
2  * File:         misc.c
3  *
4  * Description:  misc stuff
5  *
6  *
7  * This source code is part of kludge3d, and is released under the
8  * GNU General Public License.
9  *
10  *
11  */
12 
13 #include <sys/types.h>
14 #include <sys/stat.h>
15 #include <unistd.h>
16 #include <errno.h>
17 #include <fcntl.h>
18 
19 #include "misc.h"
20 
21 #ifdef MEMWATCH
22 #include "memwatch.h"
23 #endif
24 
25 
array_find(void ** array,int length,void * toFind)26 int array_find( void ** array, int length, void* toFind ) {
27 	int result = -1;
28 	int i;
29 
30 	for( i=0; i < length; i++ ) {
31 		if( array[i] == toFind )
32 			result = i;
33 	}
34 
35 	return result;
36 }
37 
file_exists(char * name)38 int file_exists( char * name ) {
39 	struct stat filestat;
40 	return !((stat( name, &filestat ) == -1) && (errno == ENOENT));
41 }
42 
43