| 149 | //----------------------------------------------------------------------------- |
| 150 | |
| 151 | bool Win32FileSystemChangeNotifier::internalAddNotification( const Path &dir ) |
| 152 | { |
| 153 | for ( U32 i = 0; i < mDirs.size(); ++i ) |
| 154 | { |
| 155 | if ( mDirs[i] == dir ) |
| 156 | return false; |
| 157 | } |
| 158 | |
| 159 | Path fullFSPath = mFS->mapTo( dir ); |
| 160 | String osPath = PathToOS( fullFSPath ); |
| 161 | |
| 162 | // Con::printf( "[Win32FileSystemChangeNotifier::internalAddNotification] : [%s]", osPath.c_str() ); |
| 163 | |
| 164 | HANDLE changeHandle = ::FindFirstChangeNotificationW( |
| 165 | osPath.utf16(), // directory to watch |
| 166 | FALSE, // do not watch subtree |
| 167 | FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_ATTRIBUTES); // watch file write changes |
| 168 | |
| 169 | if (changeHandle == INVALID_HANDLE_VALUE || changeHandle == NULL) |
| 170 | { |
| 171 | Con::errorf("[Win32FileSystemChangeNotifier::internalAddNotification] : failed on [%s] [%d]", osPath.c_str(), GetLastError()); |
| 172 | |
| 173 | return false; |
| 174 | } |
| 175 | |
| 176 | mDirs.push_back( dir ); |
| 177 | mHandleList.push_back( changeHandle ); |
| 178 | |
| 179 | return true; |
| 180 | } |
| 181 | |
| 182 | bool Win32FileSystemChangeNotifier::internalRemoveNotification( const Path &dir ) |
| 183 | { |