diff --git a/src/zm.cpp b/src/zm.cpp index 091487cda..49dd6d163 100644 --- a/src/zm.cpp +++ b/src/zm.cpp @@ -1291,14 +1291,14 @@ Event::Event( Monitor *p_monitor, time_t p_start_time ) : monitor( p_monitor ), alarm_frames = 0; tot_score = 0; max_score = 0; - sprintf( path, "%s/%04d", monitor->GetTimestampPath( 0 ), id ); + sprintf( path, "%s/%04d", monitor->Name(), id ); struct stat statbuf; errno = 0; stat( path, &statbuf ); if ( errno == ENOENT || errno == ENOTDIR ) { - if ( mkdir( path, 0777 ) ) + if ( mkdir( path, 0755 ) ) { Error(( "Can't make %s: %s\n", path, strerror(errno))); } @@ -1470,6 +1470,33 @@ Monitor::Monitor( int p_id, char *p_name, int p_function, int p_device, int p_ch if ( !capture ) { ref_image.Assign( width, height, colours, image_buffer[shared_images->last_write_index].image->buffer ); + + static char path[256]; + + sprintf( path, EVENT_DIR ); + + struct stat statbuf; + errno = 0; + stat( path, &statbuf ); + if ( errno == ENOENT || errno == ENOTDIR ) + { + if ( mkdir( path, 0755 ) ) + { + Error(( "Can't make %s: %s\n", path, strerror(errno))); + } + } + + sprintf( path, EVENT_DIR "/%s", name ); + + errno = 0; + stat( path, &statbuf ); + if ( errno == ENOENT || errno == ENOTDIR ) + { + if ( mkdir( path, 0755 ) ) + { + Error(( "Can't make %s: %s\n", path, strerror(errno))); + } + } } //if ( capture ) @@ -1626,42 +1653,6 @@ void Monitor::DumpZoneImage() zone_image.WriteJpeg( filename ); } -char *Monitor::GetTimestampPath( time_t now ) -{ - static char path[256]; - sprintf( path, "events/%s", name ); - return( path ); - - static char timestamp[64]; - static char event_path[256]; - - strftime( timestamp, sizeof(timestamp), "%Y%m%d", localtime( &now ) ); - sprintf( event_path, "events/%s/%s", name, timestamp ); - struct stat statbuf; - errno = 0; - stat( event_path, &statbuf ); - if ( errno == ENOENT || errno == ENOTDIR ) - { - if ( mkdir( event_path, 0777 ) ) - { - Error(( "Can't make %s: %s\n", event_path, strerror(errno))); - } - } - strftime( timestamp, sizeof(timestamp), "%H%M%S", localtime( &now ) ); - strcat( event_path, "/" ); - strcat( event_path, timestamp ); - errno = 0; - stat( event_path, &statbuf ); - if ( errno == ENOENT || errno == ENOTDIR ) - { - if ( mkdir( event_path, 0777 ) ) - { - Error(( "Can't make %s: %s\n", event_path, strerror(errno))); - } - } - return( event_path ); -} - void Monitor::DumpImage( Image *image ) const { if ( image_count && !(image_count%10) ) diff --git a/src/zm.h b/src/zm.h index 0876c7e70..56b16bed8 100644 --- a/src/zm.h +++ b/src/zm.h @@ -609,7 +609,6 @@ public: return( function == ACTIVE && image_count > WARMUP_COUNT ); } - char *GetTimestampPath( time_t now ); void DumpImage( Image *image ) const; void Analyse(); diff --git a/src/zmcfg.h.z b/src/zmcfg.h.z index eb3748aac..682efba9b 100644 --- a/src/zmcfg.h.z +++ b/src/zmcfg.h.z @@ -5,3 +5,5 @@ #define ZM_DB_PASSA "zmadminzm" #define ZM_DB_USERB "zmuser" #define ZM_DB_PASSB "zmuserzm" + +#define EVENT_DIR "events"