From 9a49eca6aa13543bd5966315452a11bade081292 Mon Sep 17 00:00:00 2001 From: eddyem Date: Thu, 4 May 2017 16:29:13 +0300 Subject: [PATCH] add timestamp modifying for jpeg files --- debayer.cpp | 12 ++++++++++++ debayer.h | 1 + imfunctions.c | 9 --------- socket.c | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/debayer.cpp b/debayer.cpp index d795c7a..d6d01b2 100644 --- a/debayer.cpp +++ b/debayer.cpp @@ -26,10 +26,21 @@ #include #include #include +#include #include "debayer.h" #include "usefull_macros.h" + +void modifytimestamp(const char *filename, imstorage *img){ + if(!filename) return; + struct timespec times[2]; + memset(times, 0, 2*sizeof(struct timespec)); + times[0].tv_nsec = UTIME_OMIT; + times[1].tv_sec = img->exposetime; // change mtime + if(utimensat(AT_FDCWD, filename, times, 0)) WARN(_("Can't change timestamp for %s"), filename); +} + static int write_jpeg(const char *fname, const uint8_t *data, imstorage *img){ if(!img) return 1; size_t nx = img->W, ny = img->H; @@ -73,6 +84,7 @@ static int write_jpeg(const char *fname, const uint8_t *data, imstorage *img){ gdImageJpeg(im, fp, 90); fclose(fp); gdImageDestroy(im); + modifytimestamp(fname, img); return 0; } diff --git a/debayer.h b/debayer.h index 7e350f9..517fa2f 100644 --- a/debayer.h +++ b/debayer.h @@ -31,6 +31,7 @@ extern "C" { #include "imfunctions.h" int write_debayer(imstorage *img, uint16_t black); +void modifytimestamp(const char *filename, imstorage *img); #ifdef __cplusplus } diff --git a/imfunctions.c b/imfunctions.c index 992579e..2b3a64a 100644 --- a/imfunctions.c +++ b/imfunctions.c @@ -48,15 +48,6 @@ double exp_calculated = -1.; // optimal exposition, calculated in histogram save * exposition start! */ #ifndef DAEMON -#include -void modifytimestamp(char *filename, imstorage *img){ - if(!filename) return; - struct timespec times[2]; - memset(times, 0, 2*sizeof(struct timespec)); - times[0].tv_nsec = UTIME_OMIT; - times[1].tv_sec = img->exposetime; // change mtime - if(utimensat(AT_FDCWD, filename, times, 0)) WARN(_("Can't change timestamp for %s"), filename); -} /** * NON THREAD-SAFE! diff --git a/socket.c b/socket.c index 9a7a321..b387d82 100644 --- a/socket.c +++ b/socket.c @@ -66,8 +66,8 @@ static int waittoread(int sock){ } break; }while(1); - if(FD_ISSET(sock, &fds)) return 1; if(FD_ISSET(sock, &efds)) return -1; // exception - socket closed + if(FD_ISSET(sock, &fds)) return 1; return 0; }