BlinkenArea - GitList
Repositories
Blog
Wiki
Blinker
Code
Commits
Branches
Tags
Search
Tree:
3acea4f
Branches
Tags
master
Blinker
src
windows
File.cpp
File + Directory for Windows
Stefan Schuermans
commited
3acea4f
at 2017-10-28 20:23:07
File.cpp
Blame
History
Raw
/* Blinker Copyright 2011-2014 Stefan Schuermans <stefan@blinkenarea.org> Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html a blinkenarea.org project */ #include <string> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include "File.h" #include "Time.h" namespace Blinker { /** * @brief constructor from path * @param[in] path path to file */ File::File(const std::string &path): m_path(path) { // get modification time checkModified(); } /** * @brief get path to file * @return path to file */ const std::string & File::getPath() { return m_path; } /** * @brief check if file has been modified * @return if file has been modified since last check */ bool File::checkModified() { // get modification/change times struct stat s; if (stat(m_path.c_str(), &s)) return false; // cannot stat -> silently ignore Time modifyTime(s.st_mtime); // s.st_ctime not valid for FAT filesystems, so do not use it // consider file modified if modify time changed since last check bool mod = modifyTime > m_lastModifyTime; // remember new modify time m_lastModifyTime = modifyTime; return mod; } } // namespace Blinker