From c9d1cba5d3fcaea3f5708bd54594cc000873404d Mon Sep 17 00:00:00 2001 From: peterkvt80 Date: Sun, 30 Oct 2016 01:42:33 +0100 Subject: [PATCH] Tweaks for file monitoring on Linux --- Makefile | 4 ++-- filemonitor.cpp | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 7ea664a..ec04c7d 100644 --- a/Makefile +++ b/Makefile @@ -14,9 +14,9 @@ LIBS = -lpthread -fstack-protector #Set any dependent files (e.g. header files) so that if they are edited they cause a re-compile (e.g. "main.h my_sub_functions.h some_definitions_file.h"), or leave blank -DEPS = vbit2.h service.h configure.h pagelist.h ttxpage.h packet.h tables.h mag.h ttxpagestream.h ttxline.h carousel.h +DEPS = vbit2.h service.h configure.h pagelist.h ttxpage.h packet.h tables.h mag.h ttxpagestream.h ttxline.h carousel.h filemonitor.h -OBJ = vbit2.o service.o configure.o pagelist.o ttxpage.o packet.o tables.o mag.o ttxpagestream.o ttxline.o carousel.o +OBJ = vbit2.o service.o configure.o pagelist.o ttxpage.o packet.o tables.o mag.o ttxpagestream.o ttxline.o carousel.o filemonitor.o # packet.o tables.o stream.o mag.o buffer.o page.o outputstream.o HandleTCPClient.o delay.o hamm.o nu4.o thread.o settings.o #Below here doesn't need to change diff --git a/filemonitor.cpp b/filemonitor.cpp index 2bc60c6..1e0cf76 100644 --- a/filemonitor.cpp +++ b/filemonitor.cpp @@ -78,7 +78,8 @@ void FileMonitor::run() while ((dirp = readdir(dp)) != NULL) { // Select only pages that might be teletext. tti or ttix at the moment. - char* p=strstr(dirp->d_name,".tti"); + char* p=strcasestr(dirp->d_name,".tti"); + std::cerr << path << "/" << dirp->d_name << std::endl; if (p) { std::string name; @@ -86,13 +87,10 @@ void FileMonitor::run() name+="/"; name+=dirp->d_name; // Find the modification time -struct tm* clock; // create a time structure - -struct stat attrib; // create a file attribute structure - -stat(name.c_str(), &attrib); // get the attributes of the file - -clock = gmtime(&(attrib.st_mtime)); // Get the last modified time and put it into the time structure + struct tm* clock; // create a time structure + struct stat attrib; // create a file attribute structure + stat(name.c_str(), &attrib); // get the attributes of the file + clock = gmtime(&(attrib.st_mtime)); // Get the last modified time and put it into the time structure std::cerr << path << "/" << dirp->d_name << std::dec << " time:" << clock->tm_hour << ":" << clock->tm_min << std::endl; }