Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995 - 2000.
  5. //
  6. // File: CIOPLOCK.HXX
  7. //
  8. // Contents: Oplock support for filtering documents
  9. //
  10. // Classes: CFilterOplock
  11. //
  12. // History: 03-Jul-95 DwightKr Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. //+---------------------------------------------------------------------------
  17. //
  18. // Class: CFilterOplock
  19. //
  20. // Purpose: Takes oplock on file object
  21. //
  22. // History: 03-Jul-95 DwightKr Created.
  23. //
  24. //----------------------------------------------------------------------------
  25. class CFilterOplock
  26. {
  27. public:
  28. CFilterOplock( CFunnyPath const & funnyFileName, BOOL fTakeOplock = TRUE );
  29. ~CFilterOplock();
  30. BOOL IsOplockBroken() const;
  31. BOOL IsDirectory() const { return _fDirectory; }
  32. HANDLE GetFileHandle() { return _hFileNormal; }
  33. inline void CloseFileHandle();
  34. BOOL IsOffline() const { return (0 != (_BasicInfo.FileAttributes & FILE_ATTRIBUTE_OFFLINE) ); }
  35. void MaybeSetLastAccessTime( ULONG ulDelay );
  36. BOOL IsNotContentIndexed() const
  37. {
  38. return ( 0 != ( _BasicInfo.FileAttributes &
  39. FILE_ATTRIBUTE_NOT_CONTENT_INDEXED ) );
  40. }
  41. private:
  42. FILE_BASIC_INFORMATION _BasicInfo; // Used to store last-access time, etc.
  43. HANDLE _hFileOplock; // File handle for oplock
  44. HANDLE _hFileNormal; // File handle for NtQueryInfo, etc.
  45. HANDLE _hLockEvent; // Event signaled when lock broken
  46. IO_STATUS_BLOCK _IoStatus; // Asynchronous I/O status block
  47. BOOL _fDirectory; // no oplocks on directories
  48. BOOL _fWriteAccess; // FALSE if _hFileNormal has no
  49. // attribute write access
  50. CFunnyPath const & _funnyFileName; // Filename, for MaybeSetLastAccessTime
  51. };
  52. inline void CFilterOplock::CloseFileHandle ()
  53. {
  54. if ( INVALID_HANDLE_VALUE != _hFileNormal )
  55. {
  56. NtClose( _hFileNormal );
  57. _hFileNormal = INVALID_HANDLE_VALUE;
  58. }
  59. }