diff --git a/bin/win/fsnotifier.exe b/bin/win/fsnotifier.exe index 265c94f7ea03..47c7139daf39 100644 Binary files a/bin/win/fsnotifier.exe and b/bin/win/fsnotifier.exe differ diff --git a/native/fileWatcher/fileWatcher3.cpp b/native/fileWatcher/fileWatcher3.cpp index 97c32fdbfafb..77b8f36f8e40 100644 --- a/native/fileWatcher/fileWatcher3.cpp +++ b/native/fileWatcher/fileWatcher3.cpp @@ -25,12 +25,28 @@ struct WatchRootInfo { bool bFailed; }; +struct WatchRoot { + char *path; + WatchRoot *next; +}; + const int ROOT_COUNT = 26; WatchRootInfo watchRootInfos[ROOT_COUNT]; +WatchRoot *firstWatchRoot = NULL; + CRITICAL_SECTION csOutput; +void NormalizeSlashes(char *path, char slash) +{ + for(char *p=path; *p; p++) + if (*p == '\\' || *p == '/') + *p = slash; +} + +// -- Watchable root checks --------------------------------------------------- + bool IsNetworkDrive(const char *name) { const int BUF_SIZE = 1024; @@ -48,22 +64,6 @@ bool IsNetworkDrive(const char *name) return result == NO_ERROR; } -bool IsSubstedDrive(const char* name) -{ - char deviceName[3] = {name[0], name[1], 0}; - const int BUF_SIZE = 1024; - char targetPath[BUF_SIZE]; - - DWORD result = QueryDosDeviceA(deviceName, targetPath, BUF_SIZE); - if (result == 0) { - return false; - } - else { - bool result = (targetPath[0] == '\\' && targetPath[1] == '?' && targetPath[2] == '?'); - return result; - } -} - bool IsUnwatchableFS(const char *path) { char volumeName[MAX_PATH]; @@ -89,16 +89,87 @@ bool IsWatchable(const char *path) { if (IsNetworkDrive(path)) return false; - if (IsSubstedDrive(path)) - return false; if (IsUnwatchableFS(path)) return false; return true; } +// -- Substed drive checks ---------------------------------------------------- + +void PrintRemapForSubstDrive(char driveLetter) +{ + const int BUF_SIZE = 1024; + char targetPath[BUF_SIZE]; + + char rootPath[8]; + sprintf_s(rootPath, 8, "%c:", driveLetter); + + DWORD result = QueryDosDeviceA(rootPath, targetPath, BUF_SIZE); + if (result == 0) { + return; + } + else + { + if (targetPath[0] == '\\' && targetPath[1] == '?' && targetPath[2] == '?' && targetPath[3] == '\\') + { + // example path: \??\C:\jetbrains\idea + NormalizeSlashes(targetPath, '/'); + printf("%c:\n%s\n", driveLetter, targetPath+4); + } + } +} + +void PrintRemapForSubstDrives() +{ + for(int i=0; ipath); + pWatchRoot = pWatchRoot->next; + } +} + +// -- Watcher thread ---------------------------------------------------------- + void PrintChangeInfo(char *rootPath, FILE_NOTIFY_INFORMATION *info) { char FileNameBuffer[_MAX_PATH]; @@ -253,6 +369,8 @@ DWORD WINAPI WatcherThread(void *param) return 0; } +// -- Roots update ------------------------------------------------------------ + void MarkAllRootsUnused() { for(int i=0; inext = NULL; + watchRoot->path = _strdup(path); + watchRoot->next = firstWatchRoot; + firstWatchRoot = watchRoot; +} + +void FreeWatchRootsList() +{ + WatchRoot *pWatchRoot = firstWatchRoot; + WatchRoot *pNext; + while(pWatchRoot) + { + pNext = pWatchRoot->next; + free(pWatchRoot->path); + free(pWatchRoot); + pWatchRoot=pNext; + } + firstWatchRoot = NULL; +} + +// -- Main - filewatcher protocol --------------------------------------------- + int _tmain(int argc, _TCHAR* argv[]) { InitializeCriticalSection(&csOutput); @@ -340,6 +491,7 @@ int _tmain(int argc, _TCHAR* argv[]) if (!strcmp(buffer, "ROOTS")) { MarkAllRootsUnused(); + FreeWatchRootsList(); bool failed = false; while(true) { @@ -351,10 +503,14 @@ int _tmain(int argc, _TCHAR* argv[]) if (buffer [0] == '#') break; int driveLetterPos = 0; + char *pDriveLetter = buffer; + if (*pDriveLetter == '|') + pDriveLetter++; + + AddWatchRoot(pDriveLetter); + _strupr_s(buffer, sizeof(buffer)-1); - char driveLetter = buffer[0]; - if (driveLetter == '|') - driveLetter = buffer[1]; + char driveLetter = *pDriveLetter; if (driveLetter >= 'A' && driveLetter <= 'Z') { watchRootInfos [driveLetter-'A'].bUsed = true; diff --git a/native/fileWatcher/fileWatcher3.rc b/native/fileWatcher/fileWatcher3.rc index 4956f6958f9c..a2ed61e673e3 100644 --- a/native/fileWatcher/fileWatcher3.rc +++ b/native/fileWatcher/fileWatcher3.rc @@ -73,7 +73,7 @@ BEGIN VALUE "FileDescription", "File System Notification Processor" VALUE "FileVersion", "1, 0, 0, 1" VALUE "InternalName", "fsnotifier" - VALUE "LegalCopyright", "Copyright (C) 2008 JetBrains, Inc." + VALUE "LegalCopyright", "Copyright (C) 2008-09 JetBrains, Inc." VALUE "OriginalFilename", "fsnotifier.exe" VALUE "ProductName", "IntelliJ IDEA" VALUE "ProductVersion", "1, 0, 0, 1" diff --git a/native/fileWatcher/fileWatcher3.vcproj b/native/fileWatcher/fileWatcher3.vcproj index e1b797fdd423..14ec211e54f3 100644 --- a/native/fileWatcher/fileWatcher3.vcproj +++ b/native/fileWatcher/fileWatcher3.vcproj @@ -62,7 +62,7 @@ Name="VCLinkerTool" AdditionalDependencies="mpr.lib" OutputFile="$(OutDir)\fsnotifier.exe" - LinkIncremental="2" + LinkIncremental="1" GenerateDebugInformation="true" SubSystem="1" TargetMachine="1"