From d052e4c79d8e69a14221c6e2cbd8989dac6609b6 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 23 May 2020 13:56:09 +0200 Subject: [PATCH] Substitution-less source file validator. --- server/TracyFilesystem.cpp | 10 ++++++++++ server/TracyFilesystem.hpp | 1 + 2 files changed, 11 insertions(+) diff --git a/server/TracyFilesystem.cpp b/server/TracyFilesystem.cpp index e33de71c..6b4bdd8a 100644 --- a/server/TracyFilesystem.cpp +++ b/server/TracyFilesystem.cpp @@ -14,4 +14,14 @@ bool SourceFileValid( const char* fn, uint64_t olderThan, const View& view ) return false; } +bool SourceFileValid( const char* fn, uint64_t olderThan ) +{ + struct stat buf; + if( stat( fn, &buf ) == 0 && ( buf.st_mode & S_IFREG ) != 0 ) + { + return (uint64_t)buf.st_mtime < olderThan; + } + return false; +} + } diff --git a/server/TracyFilesystem.hpp b/server/TracyFilesystem.hpp index 40c9a62f..8b246dee 100644 --- a/server/TracyFilesystem.hpp +++ b/server/TracyFilesystem.hpp @@ -16,6 +16,7 @@ static inline bool FileExists( const char* fn ) } bool SourceFileValid( const char* fn, uint64_t olderThan, const View& view ); +bool SourceFileValid( const char* fn, uint64_t olderThan ); }