portability improvement. replace POSIX-only functionality.

This commit is contained in:
Axel Kohlmeyer 2021-04-24 07:14:29 -04:00
parent e980d17882
commit 0aa64eaf14
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
1 changed files with 4 additions and 6 deletions

View File

@ -10,14 +10,12 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifndef TEST_EXTENSIONS__H
#define TEST_EXTENSIONS__H
#ifndef LMP_TESTING_UTILS_H
#define LMP_TESTING_UTILS_H
#include <fstream>
#include <iostream>
#include <string>
#include <sys/stat.h>
#include <sys/types.h>
#include <vector>
static void delete_file(const std::string &filename)
@ -65,8 +63,8 @@ static std::vector<std::string> read_lines(const std::string &filename)
static bool file_exists(const std::string &filename)
{
struct stat result;
return stat(filename.c_str(), &result) == 0;
std::ifstream infile(filename);
return infile.good();
}
#define ASSERT_FILE_EXISTS(NAME) ASSERT_TRUE(file_exists(NAME))