void CChangeTray::AddChange(__in double value) { AddChange(value, 1); }
void FileWatcher::ThreadFunction() { #if defined(ENABLE_FILEWATCHER) #if defined(WIN32) unsigned char buffer[BUFFERSIZE]; DWORD bytesFilled = 0; while (shouldRun_) { if (ReadDirectoryChangesW((HANDLE)dirHandle_, buffer, BUFFERSIZE, watchSubDirs_, FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE, &bytesFilled, 0, 0)) { unsigned offset = 0; while (offset < bytesFilled) { FILE_NOTIFY_INFORMATION* record = (FILE_NOTIFY_INFORMATION*)&buffer[offset]; if (record->Action == FILE_ACTION_MODIFIED || record->Action == FILE_ACTION_RENAMED_NEW_NAME) { String fileName; const wchar_t* src = record->FileName; const wchar_t* end = src + record->FileNameLength / 2; while (src < end) fileName.AppendUTF8(String::DecodeUTF16(src)); fileName = GetInternalPath(fileName); AddChange(fileName); } if (!record->NextEntryOffset) break; else offset += record->NextEntryOffset; } } } #elif defined(__linux__) unsigned char buffer[BUFFERSIZE]; while (shouldRun_) { int i = 0; int length = read(watchHandle_, buffer, sizeof(buffer)); if (length < 0) return; while (i < length) { inotify_event* event = (inotify_event*)&buffer[i]; if (event->len > 0) { if (event->mask & IN_MODIFY || event->mask & IN_MOVE) { String fileName; fileName = dirHandle_[event->wd] + event->name; AddChange(fileName); } } i += sizeof(inotify_event) + event->len; } } #elif defined(__APPLE__) && !defined(IOS) while (shouldRun_) { Time::Sleep(100); String changes = ReadFileWatcher(watcher_); if (!changes.Empty()) { Vector<String> fileNames = changes.Split(1); for (unsigned i = 0; i < fileNames.Size(); ++i) AddChange(fileNames[i]); } } #endif #endif }