From 95087beeb97a01ef38fdca5e1eaf888292e118b4 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 12 Aug 2015 11:00:41 -0400 Subject: [PATCH] use return value of stat instead of just checking errno. This has the added benefit of catching other errors when stating --- src/zm_event.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 3e723fa48..72df9a1cf 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -119,13 +119,16 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string struct stat statbuf; errno = 0; - stat( path, &statbuf ); - if ( errno == ENOENT || errno == ENOTDIR ) - { - if ( mkdir( path, 0755 ) ) - { - Fatal( "Can't mkdir %s: %s", path, strerror(errno)); - } + if ( stat( path, &statbuf ) ) { + if ( errno == ENOENT || errno == ENOTDIR ) + { + if ( mkdir( path, 0755 ) ) + { + Fatal( "Can't mkdir %s: %s", path, strerror(errno)); + } + } else { + Warning( "Error stat'ing %s, may be fatal. error is %s", path, strerror(errno)); + } } if ( i == 2 ) strncpy( date_path, path, sizeof(date_path) );