use return value of stat instead of just checking errno. This has the added benefit of catching other errors when stating

This commit is contained in:
Isaac Connor 2015-08-12 11:00:41 -04:00
parent fcc1f9705f
commit 95087beeb9
1 changed files with 10 additions and 7 deletions

View File

@ -119,13 +119,16 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
struct stat statbuf; struct stat statbuf;
errno = 0; errno = 0;
stat( path, &statbuf ); if ( stat( path, &statbuf ) ) {
if ( errno == ENOENT || errno == ENOTDIR ) if ( errno == ENOENT || errno == ENOTDIR )
{ {
if ( mkdir( path, 0755 ) ) if ( mkdir( path, 0755 ) )
{ {
Fatal( "Can't mkdir %s: %s", path, strerror(errno)); 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 ) if ( i == 2 )
strncpy( date_path, path, sizeof(date_path) ); strncpy( date_path, path, sizeof(date_path) );