File tree Expand file tree Collapse file tree
include/neuralnetwork/libraries Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3838 #include < fcntl.h>
3939 #endif
4040#endif
41+ #include < sys/types.h>
42+ #include < sys/stat.h>
4143
4244static constexpr short TJ_MAX_NUMBER_OF_DIGGITS = 19 ;
4345static 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 {
You can’t perform that action at this time.
0 commit comments