add timestamp modifying for jpeg files

This commit is contained in:
eddyem 2017-05-04 16:29:13 +03:00
parent bf34128607
commit 9a49eca6aa
4 changed files with 14 additions and 10 deletions

View File

@ -26,10 +26,21 @@
#include <unistd.h>
#include <libraw/libraw.h>
#include <gd.h>
#include <time.h>
#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;
}

View File

@ -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
}

View File

@ -48,15 +48,6 @@ double exp_calculated = -1.; // optimal exposition, calculated in histogram save
* exposition start!
*/
#ifndef DAEMON
#include <time.h>
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!

View File

@ -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;
}