C++17 Filesystem – Writing a simple file watcher
solarianprogrammer.com
C++17 Filesystem – Writing a simple file watcher
1–10 of 16 posts
Re: C++17 Filesystem – Writing a simple file watcher
#2https://en.cppreference.com/w/cpp/container/unordered_map/co...
Re: C++17 Filesystem – Writing a simple file watcher
#3std::unordered_map has method count(), C++20 will be probably just a wrapper for the method. https://en.cppreference.com/w/cpp/container/unordered_map/co...
Re: C++17 Filesystem – Writing a simple file watcher
#4Re: C++17 Filesystem – Writing a simple file watcher
#5Re: C++17 Filesystem – Writing a simple file watcher
#6Re: C++17 Filesystem – Writing a simple file watcher
#7Those files have so many "std::" references. Would this not be a good case to utilize "using namespace std"?
[0] https://github.com/sol-prog/cpp17-filewatcher/blob/master/Fi...
Re: C++17 Filesystem – Writing a simple file watcher
#8When you do that kind of stuff, keep in mind that many programs modify files by writing to a temp file and then renaming that file.
On a secondary note, "modern C++" needs to be stopped. This is absurd:
std::chrono::duration
Just say no. Don't include stuff like or . Ignore Bjarne's opinions. Don't read books by Scott Meyers. Being effective with C++ means understanding its "powers" and then not using them.
Re: C++17 Filesystem – Writing a simple file watcher
#9Re: C++17 Filesystem – Writing a simple file watcher
#10Guys, don't do this. There are OS-specific APIs to do this stuff efficiently. No, that's not portable. No, those APIs aren't "nice to use". But it's the "right" way to do it. When you do that kind of stuff, keep in mind that many programs modify files by writing to a temp file and then renaming that file. On a secondary note, "modern C++" needs to be stopped. This is absurd: std::chrono::duration Just say no. Don't i…
The code has sleep calls and polls the filesystem. The nonportable OS support will actually block and have the kernel wake you up when there are actual changes - and not wake you when there is no change - much kinder on the CPU!
Just say no indeed, to polling the filesystem with sleep calls. (Maybe as a last resort if the OS specific support is unavailable?)