// This function walks all watched files, collects changes, and updates state private FileChangeList ComputeChangesAndUpdateState() { _version++; var changes = new FileChangeList(); WIN32_FIND_DATAW fileData = new WIN32_FIND_DATAW(); unsafe { WIN32_FIND_DATAW *pFileData = &fileData; for (int index = 0; index < _directories.Count; index++) { var directory = _directories[index]; var handle = DllImports.FindFirstFileExW(directory, FINDEX_INFO_LEVELS.FindExInfoBasic, pFileData, FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, DllImports.FIND_FIRST_EX_LARGE_FETCH); if (handle == DllImports.INVALID_HANDLE_VALUE) // directory got deleted { if (Tracing.Switch.ShouldTrace(TraceEventType.Information)) { Tracing.TraceEvent(TraceEventType.Warning, 2, "Directory could not be opened {0}", directory); } _directories.Remove(directory); continue; } try { do { if (IsSpecial(fileData.cFileName)) { continue; } if (!IsWatched(fileData.cFileName)) { continue; } UpdateState(directory, ref changes, ref fileData, fileData.cFileName); }while (DllImports.FindNextFileW(handle, pFileData)); } finally { DllImports.FindClose(handle); } } } foreach (var value in _state) { if (value._version != _version) { changes.AddRemoved(value.Directory, value.Path); _state.Remove(value.Directory, value.Path); } } return(changes); }
public static extern int FindNextFileW([NativeTypeName("HANDLE")] IntPtr hFindFile, [NativeTypeName("LPWIN32_FIND_DATAW")] WIN32_FIND_DATAW *lpFindFileData);
public static extern IntPtr FindFirstFileW([NativeTypeName("LPCWSTR")] ushort *lpFileName, [NativeTypeName("LPWIN32_FIND_DATAW")] WIN32_FIND_DATAW *lpFindFileData);
public HRESULT GetPath([NativeTypeName("LPWSTR")] ushort *pszFile, int cch, WIN32_FIND_DATAW *pfd, [NativeTypeName("DWORD")] uint fFlags) { return(((delegate * unmanaged <IShellLinkW *, ushort *, int, WIN32_FIND_DATAW *, uint, int>)(lpVtbl[3]))((IShellLinkW *)Unsafe.AsPointer(ref this), pszFile, cch, pfd, fFlags)); }
public static extern BOOL FindNextFileW(HANDLE hFindFile, [NativeTypeName("LPWIN32_FIND_DATAW")] WIN32_FIND_DATAW *lpFindFileData);
public HRESULT GetFindData(WIN32_FIND_DATAW *pfd) { return(((delegate * unmanaged <IFileSystemBindData *, WIN32_FIND_DATAW *, int>)(lpVtbl[4]))((IFileSystemBindData *)Unsafe.AsPointer(ref this), pfd)); }
public HRESULT SetFindData([NativeTypeName("const WIN32_FIND_DATAW *")] WIN32_FIND_DATAW *pfd) { return(((delegate * unmanaged <IFileSystemBindData *, WIN32_FIND_DATAW *, int>)(lpVtbl[3]))((IFileSystemBindData *)Unsafe.AsPointer(ref this), pfd)); }