This commit is contained in:
Nicholas Hastings
2011-04-13 08:31:02 -04:00
2 changed files with 17 additions and 0 deletions
+1
View File
@@ -40,3 +40,4 @@ crab
jibbly jibbly jibbly
oh mercurial
hi
oh, hello
+16
View File
@@ -29,6 +29,11 @@
#include "sc.h"
#include "memfile.h"
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined DARWIN
#include <sys/types.h>
#include <sys/stat.h>
#endif
/* pc_printf()
* Called for general purpose "console" output. This function prints general
* purpose messages; errors go through pc_error(). The function is modelled
@@ -100,6 +105,17 @@ static char *prefix[3]={ "error", "fatal error", "warning" };
*/
void *pc_opensrc(char *filename)
{
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined DARWIN
struct stat fileInfo;
if (stat(filename, &fileInfo) != 0) {
return NULL;
}
if (S_ISDIR(fileInfo.st_mode)) {
return NULL;
}
#endif
return fopen(filename,"rt");
}