Skip to content

Commit

Permalink
Tweaks for file monitoring on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
peterkvt80 committed Oct 30, 2016
1 parent 83cf041 commit c9d1cba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions filemonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,19 @@ 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;
name=path;
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;
}
Expand Down

0 comments on commit c9d1cba

Please sign in to comment.