diff --git a/README.md b/README.md index 1efb86f..ac490b0 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Once mounted, the files can be xbox-iso-vfs.exe [/d|/l] /d Display debug Dokan output in console window + /l Open Windows Explorer to the mount path Path to the Xbox ISO file to mount Driver letter ("M:\") or folder path on NTFS partition /h Show usage diff --git a/src/main.cc b/src/main.cc index 3d42076..8a3d456 100644 --- a/src/main.cc +++ b/src/main.cc @@ -6,10 +6,12 @@ #include "vfs.h" #include "vfs_operations.h" +#include #include #include #include #include +#include template class Singleton { public: @@ -33,7 +35,7 @@ class App : public Singleton { std::wstring filePath; std::wstring mountPoint; bool debugMode{false}; - // bool launchMountPath{ true }; + bool launchMountPath{false}; }; App(const Parameters ¶ms) : m_params(params) {} @@ -57,6 +59,16 @@ class App : public Singleton { } } + static void fileWatcher(std::wstring path) { + std::filesystem::path mp(path); + + do { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + } while (std::filesystem::exists(mp) == false); + + ShellExecuteW(0, L"explore", path.c_str(), NULL, NULL, SW_SHOWNORMAL); + } + void runDokan() { DOKAN_OPTIONS dokanOptions; ZeroMemory(&dokanOptions, sizeof(DOKAN_OPTIONS)); @@ -82,6 +94,11 @@ class App : public Singleton { vfs::setup(dokanOperations); + std::thread watcher; + if (m_params.launchMountPath) { + watcher = std::thread(fileWatcher, m_params.mountPoint); + } + auto status = DokanMain(&dokanOptions, &dokanOperations); // Solutions are suggested where possible @@ -125,16 +142,20 @@ class App : public Singleton { std::wcout << "Please create an issue on Github with this number\n"; break; } + + if (watcher.joinable()) { + watcher.detach(); + } } static void showUsage() { std::wcout << "xbox-iso-vfs is a utility to mount Xbox ISO files on Windows\n"; std::wcout << "Written by x1nixmzeng\n\n"; - std::wcout << "xbox-iso-vfs.exe [/d] \n"; + std::wcout << "xbox-iso-vfs.exe [/d|/l] \n"; std::wcout << " /d Display debug Dokan output in console window\n"; - // std::wcout << " /l Launch the mount path when successful\n"; + std::wcout << " /l Open Windows Explorer to the mount path\n"; std::wcout << " Path to the Xbox ISO file to mount\n"; std::wcout << " Driver letter (\"M:\\\") or folder path on " "NTFS partition\n"; @@ -154,11 +175,10 @@ class App : public Singleton { } else if (arg == L"--debug" || arg == L"/d") { params.debugMode = true; continue; - } - // else if (arg == L"--launch" || arg == L"/l") { - // params.launchMountPath = true; - //} - else if (i + 1 >= argc) { + } else if (arg == L"--launch" || arg == L"/l") { + params.launchMountPath = true; + continue; + } else if (i + 1 >= argc) { std::wcout << "Missing mount_path parameter. Use --help to see usage\n"; return false; }