diff --git a/ml_io.cpp b/ml_io.cpp index a5ac3b2..ab0cfed 100644 --- a/ml_io.cpp +++ b/ml_io.cpp @@ -50,8 +50,13 @@ MlValue list_dir(const std::string &path) { } bool is_path_file(const std::string &path) { - std::ifstream ifile(path.c_str()); - return (bool) ifile; + struct stat buf{}; + stat(path.c_str(), &buf); + return (bool) S_ISREG(buf.st_mode) || + (bool) S_ISBLK(buf.st_mode) || + (bool) S_ISCHR(buf.st_mode) || + (bool) S_ISFIFO(buf.st_mode) || + (bool) S_ISSOCK(buf.st_mode); } bool is_path_dir(const std::string &path) {