Browse Source

Merge e0bf3cc22b into ec4879ac5b

pull/162/merge
Alexandru Ardelean 10 years ago
parent
commit
938d3ccf67
1 changed files with 14 additions and 0 deletions
  1. +14
    -0
      json_util.c

+ 14
- 0
json_util.c View File

@@ -71,6 +71,20 @@ struct json_object* json_object_from_file(const char *filename)
char buf[JSON_FILE_BUF_SIZE];
int fd, ret;

#ifdef HAVE_SYS_STAT_H
struct stat st;

if (stat(filename, &st) < 0) {
MC_ERROR("json_object_from_file: could not stat file %s: %s\n",
filename, strerror(errno));
return NULL;
}
if ((st.st_mode & S_IFMT) == S_IFDIR) {
MC_ERROR("json_object_from_file: path is a directory %s: %s\n",
filename, strerror(errno));
}
#endif

if((fd = open(filename, O_RDONLY)) < 0) {
MC_ERROR("json_object_from_file: error opening file %s: %s\n",
filename, strerror(errno));


Loading…
Cancel
Save