14 #include <boost/tokenizer.hpp>
15 #include <boost/array.hpp>
16 #include <boost/system/error_code.hpp>
25 #if defined(_UNICODE) || defined(UNICODE)
27 std::wstring path = L
"")
31 path = ::_wgetenv(L
"PATH");
34 "Environment variable PATH not found"));
37 typedef boost::tokenizer < boost::char_separator<wchar_t>,
38 std::wstring::const_iterator, std::wstring > tokenizer;
39 boost::char_separator<wchar_t> sep(L
";");
40 tokenizer tok(path, sep);
41 for (tokenizer::iterator it = tok.begin(); it != tok.end(); ++it)
43 std::filesystem::path p = *it;
45 boost::array<std::wstring, 4> extensions =
46 { L
"", L
".exe", L
".com", L
".bat" };
47 for (boost::array<std::wstring, 4>::iterator it2 = extensions.begin();
48 it2 != extensions.end(); ++it2)
50 std::filesystem::path p2 = p;
52 boost::system::error_code ec;
53 bool file = std::filesystem::is_regular_file(p2, ec);
55 SHGetFileInfoW(p2.c_str(), 0, 0, 0, SHGFI_EXETYPE))
65 std::string path =
"")
69 path = ::getenv(
"PATH");
72 "Environment variable PATH not found"));
75 using tokenizer = boost::tokenizer<boost::char_separator<char> >;
76 boost::char_separator<char> sep(
";");
77 tokenizer tok(path, sep);
78 for (tokenizer::iterator it = tok.begin(); it != tok.end(); ++it)
80 std::filesystem::path p = *it;
82 boost::array<std::string, 4> extensions =
83 {
"",
".exe",
".com",
".bat" };
84 for (boost::array<std::string, 4>::iterator it2 = extensions.begin();
85 it2 != extensions.end(); ++it2)
87 std::filesystem::path p2 = p;
89 boost::system::error_code ec;
90 bool file = std::filesystem::is_regular_file(p2, ec);
92 SHGetFileInfoA(p2.string().c_str(), 0, 0, 0, SHGFI_EXETYPE))