1
0
mirror of https://github.com/fuse-friends/fuse-native synced 2024-10-27 18:34:01 +00:00

invoke dokanctl.exe to unmount paths on Windows

This commit is contained in:
Raymond Hammarling 2015-08-07 00:46:14 +02:00
parent 5dc0ab7acf
commit 89f657fbda
2 changed files with 17 additions and 1 deletions

View File

@ -37,8 +37,23 @@ void thread_join (HANDLE thread) {
WaitForSingleObject(thread, INFINITE);
}
#include <iostream>
void fusermount (char *path) {
// TODO
char cmdLine[MAX_PATH];
sprintf(cmdLine, "dokanctl.exe /u %s", path);
STARTUPINFO info = {sizeof(info)};
PROCESS_INFORMATION procInfo;
CreateProcess(NULL, cmdLine, NULL, NULL, false, CREATE_NO_WINDOW, NULL, NULL, &info, &procInfo);
WaitForSingleObject(procInfo.hProcess, INFINITE);
CloseHandle(procInfo.hProcess);
CloseHandle(procInfo.hThread);
// dokanctl.exe requires admin permissions for some reason, so if node is not run as admin,
// it'll fail to create the process for unmounting. The path will be unmounted once
// the process is killed, however, so there's that!
}
#else

View File

@ -56,6 +56,7 @@ fuse.mount(mountPath, {
process.on('SIGINT', function () {
fuse.unmount(mountPath, function () {
console.log('filesystem at ' + mountPath + ' unmounted')
process.exit()
})
})