ThomasMonkman / filewatch

File watcher in c++
MIT License
426 stars 70 forks source link

Seems doesnt work in Windows? #16

Open realquantumcookie opened 6 years ago

realquantumcookie commented 6 years ago
#include <FileWatch.hpp>
#include <iostream>
int main(int argc, char** args) {
    //FileWatch API, see here:
    //https://github.com/ThomasMonkman/filewatch
    std::string FileName ="E:\\233.txt";
    filewatch::FileWatch<std::string>(
        FileName ,
        [](const std::string& path, const filewatch::Event change_type) {
            switch(change_type) {
            case filewatch::Event::added:
                std::cout << "The file was added to the directory." << '\n';
                break;
            case filewatch::Event::removed:
                std::cout << "The file was removed from the directory." << '\n';
                break;
            case filewatch::Event::modified:
                std::cout << "The file was modified. This can be a change in the time stamp or attributes." << '\n';
                break;
            case filewatch::Event::renamed_old:
                std::cout << "The file was renamed and this is the old name." << '\n';
                break;
            case filewatch::Event::renamed_new:
                std::cout << "The file was renamed and this is the new name." << '\n';
                break;
            }
        }
        );
    std::cin.get();
}

This is the code I put in Visual Studio 2017. But it says cannot cast from initializer list to std::basic_string<char,std::char_traits,std::allocator> (which is the class of std::string) on line 366.

ThomasMonkman commented 5 years ago

ah yes, this might be due to windows using wchar_t, and also a mix of windows using the UNICODE and not using it.

Can you provide the full error output from visual studio? or the template error message?

I'll look in to this when I can.

RicoP commented 2 years ago

Is this still an issue?