#include <grpc/support/port_platform.h>
#ifdef GPR_WINDOWS_STAT
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/stat.h"
#include "src/core/lib/gprpp/strerror.h"
namespace grpc_core {
absl::Status GetFileModificationTime(const char* filename, time_t* timestamp) {
GPR_ASSERT(filename != nullptr);
GPR_ASSERT(timestamp != nullptr);
struct _stat buf;
if (_stat(filename, &buf) != 0) {
std::string error_msg = StrError(errno);
gpr_log(GPR_ERROR, "_stat failed for filename %s with error %s.", filename,
error_msg.c_str());
return absl::Status(absl::StatusCode::kInternal, error_msg);
}
*timestamp = buf.st_mtime;
return absl::OkStatus();
}
}
#endif