From 5058addf70585232934fb07aa4b528e336776fb4 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Wed, 11 Jun 2014 16:04:02 +0200 Subject: [PATCH] Fixed updating of old DTSH files not happening. --- src/input/input.cpp | 30 ++++++++++++++++++++++++++++++ src/input/input.h | 1 + 2 files changed, 31 insertions(+) diff --git a/src/input/input.cpp b/src/input/input.cpp index 2549bd43..a4f3dadb 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -68,6 +68,35 @@ namespace Mist { isBuffer = false; } + void Input::checkHeaderTimes(std::string streamFile){ + std::string headerFile = streamFile + ".dtsh"; + FILE * tmp = fopen(headerFile.c_str(),"r"); + if (tmp == NULL) { + INFO_MSG("can't open file: %s (no header times compared, nothing removed)", headerFile.c_str() ); + return; + } + struct stat bufStream; + struct stat bufHeader; + //fstat(fileno(streamFile), &bufStream); + //fstat(fileno(tmp), &bufHeader); + + if (stat(streamFile.c_str(), &bufStream) !=0 || stat(headerFile.c_str(), &bufHeader) !=0){ + ERROR_MSG("could not get file info (no header times compared, nothing removed)"); + fclose(tmp); + return; + } + + int timeStream = bufStream.st_mtime; + int timeHeader = bufHeader.st_mtime; + fclose(tmp); + INFO_MSG("time header: %i time stream: %i ", timeHeader, timeStream); + if (timeHeader < timeStream) { + INFO_MSG("removing old header file: %s ",headerFile.c_str()); + //delete filename + remove(headerFile.c_str()); + } + } + int Input::run() { if (config->getBool("json")) { std::cerr << capa.toString() << std::endl; @@ -77,6 +106,7 @@ namespace Mist { std::cerr << config->getString("cmd") << " setup failed." << std::endl; return 0; } + checkHeaderTimes(config->getString("input")); if (!readHeader()) { std::cerr << "Reading header for " << config->getString("input") << " failed." << std::endl; return 0; diff --git a/src/input/input.h b/src/input/input.h index 98425e4a..1adf74d1 100644 --- a/src/input/input.h +++ b/src/input/input.h @@ -39,6 +39,7 @@ namespace Mist { void play(int until = 0); void playOnce(); void quitPlay(); + void checkHeaderTimes(std::string streamFile); virtual void removeUnused(); virtual void trackSelect(std::string trackSpec){}; virtual void userCallback(char * data, size_t len, unsigned int id);