Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <boost/filesystem.hpp>
- #include <filesystem>
- #include <chrono>
- #include <thread>
- using namespace std;
- using chrono::system_clock;
- void PrintText(string& line) {
- string tline;
- ifstream myFile;
- myFile.open("C:\\Users\\Toffer\\Desktop\\testfile.txt");
- getline(myFile, tline);
- if (tline.substr(0, 1) == "@")
- if (tline != line) {
- line = tline;
- cout << line << endl;
- }
- myFile.close();
- }
- //void last_file_change(const filesystem::path& filename) {
- // auto file_time = filesystem::last_write_time(filename);
- // while (true) {
- // if (filesystem::last_write_time(filename) != file_time) {
- // file_time = filesystem::last_write_time(filename);
- // PrintText(line);
- // this_thread::sleep_for(chrono::seconds(3));
- // }
- // }
- //
- //}
- void copy_logfile() {
- std::filesystem::copy_file("C:\\Users\\Toffer\\Desktop\\extreme.txt", "C:\\Users\\Toffer\\Desktop\\testfile.txt", std::filesystem::copy_options::overwrite_existing);
- }
- void RefreshText(const filesystem::path& filename) {
- string line;
- auto file_time = filesystem::last_write_time(filename);
- while (true) {
- if (filesystem::last_write_time(filename) != file_time) {
- file_time = filesystem::last_write_time(filename);
- PrintText(line);
- //this_thread::sleep_for(chrono::seconds(3));
- }
- }
- }
- int main() {
- copy_logfile();
- RefreshText("C:\\Users\\Toffer\\Desktop\\extreme.txt");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement