Skip to content

Commit 60230a9

Browse files
committed
Updated TinyJSON
1 parent bfe007a commit 60230a9

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

include/neuralnetwork/libraries/TinyJSON.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#include <fcntl.h>
3939
#endif
4040
#endif
41+
#include <sys/types.h>
42+
#include <sys/stat.h>
4143

4244
static constexpr short TJ_MAX_NUMBER_OF_DIGGITS = 19;
4345
static constexpr short TJ_DEFAULT_STRING_READ_SIZE = 10;
@@ -4010,6 +4012,20 @@ namespace TinyJSON
40104012
return nullptr;
40114013
}
40124014

4015+
#if TJ_USE_CHAR == 1
4016+
#if defined(_WIN32)
4017+
struct _stat path_stat;
4018+
if (_stat(file_path, &path_stat) == 0 && (path_stat.st_mode & _S_IFDIR) != 0)
4019+
#else
4020+
struct stat path_stat;
4021+
if (stat(file_path, &path_stat) == 0 && S_ISDIR(path_stat.st_mode))
4022+
#endif
4023+
{
4024+
report_file_open_error(file_path, EISDIR, parse_options);
4025+
return nullptr;
4026+
}
4027+
#endif
4028+
40134029
std::ifstream file(file_path, std::ios::binary | std::ios::ate);
40144030
if (!file.is_open())
40154031
{

0 commit comments

Comments
 (0)