Fix compiler hanging when #including a directory (bug 4822, r=dvander)
This commit is contained in:
parent
935a8d36da
commit
86a1641ac1
@ -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");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user