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.

170 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. drfsfile
  5. Abstract:
  6. This module implements file specific operations for file system redirection.
  7. Author:
  8. JoyC 11/10/1999
  9. Revision History:
  10. --*/
  11. #include <precom.h>
  12. #define TRC_FILE "drfsfile"
  13. #include "drfsfile.h"
  14. ///////////////////////////////////////////////////////////////
  15. //
  16. // W32File Methods
  17. //
  18. //
  19. DrFSFile::DrFSFile(
  20. DrDevice *Drive,
  21. ULONG FileId,
  22. DRFILEHANDLE FileHandle,
  23. BOOL IsDirectory,
  24. DRSTRING FileName) : DrFile(Drive, FileId, FileHandle)
  25. /*++
  26. Routine Description:
  27. Constructor
  28. Arguments:
  29. Return Value:
  30. NA
  31. --*/
  32. {
  33. #ifndef OS_WINCE
  34. unsigned len;
  35. #endif
  36. DC_BEGIN_FN("DrFSFile::DrFSFile");
  37. _SearchHandle = INVALID_TS_FILEHANDLE;
  38. _NotifyHandle = INVALID_TS_FILEHANDLE;
  39. _IsDirectory = IsDirectory;
  40. _bCancel = FALSE;
  41. //
  42. // Record the file name.
  43. //
  44. ASSERT(FileName != NULL);
  45. #ifndef OS_WINCE
  46. len = _tcslen(FileName) + 1;
  47. _FileName = new TCHAR[len];
  48. if (_FileName != NULL) {
  49. //Buffer is allocated large enough for the name
  50. StringCchCopy(_FileName,len, FileName);
  51. }
  52. #else
  53. _tcsncpy(_FileName, FileName, MAX_PATH-1);
  54. #endif
  55. }
  56. DrFSFile::~DrFSFile()
  57. /*++
  58. Routine Description:
  59. Destructor
  60. Arguments:
  61. Return Value:
  62. NA
  63. --*/
  64. {
  65. DC_BEGIN_FN("DrFSFile::~DrFSFile");
  66. ASSERT(_SearchHandle == INVALID_TS_FILEHANDLE);
  67. ASSERT(_NotifyHandle == INVALID_TS_FILEHANDLE);
  68. #ifndef OS_WINCE
  69. if (_FileName) {
  70. delete _FileName;
  71. }
  72. #endif
  73. }
  74. DRFILEHANDLE DrFSFile::GetSearchHandle()
  75. {
  76. return _SearchHandle;
  77. }
  78. DRFILEHANDLE DrFSFile::GetNotifyHandle()
  79. {
  80. return _NotifyHandle;
  81. }
  82. BOOL DrFSFile::SetSearchHandle(DRFILEHANDLE SearchHandle)
  83. {
  84. _SearchHandle = SearchHandle;
  85. return TRUE;
  86. }
  87. BOOL DrFSFile::SetNotifyHandle(DRFILEHANDLE NotifyHandle)
  88. {
  89. BOOL ret = FALSE;
  90. if (_bCancel == FALSE) {
  91. _NotifyHandle = NotifyHandle;
  92. ret = TRUE;
  93. }
  94. return ret;
  95. }
  96. BOOL DrFSFile::Close()
  97. /*++
  98. Routine Description:
  99. Close the file
  100. Arguments:
  101. NA
  102. Return Value:
  103. TRUE/FALSE
  104. --*/
  105. {
  106. DC_BEGIN_FN("DrFSFile::Close");
  107. _bCancel = TRUE;
  108. if (_SearchHandle != INVALID_TS_FILEHANDLE) {
  109. FindClose(_SearchHandle);
  110. _SearchHandle = INVALID_TS_FILEHANDLE;
  111. }
  112. #if (!defined(OS_WINCE)) || (!defined(WINCE_SDKBUILD))
  113. if (_NotifyHandle != INVALID_TS_FILEHANDLE) {
  114. FindCloseChangeNotification(_NotifyHandle);
  115. _NotifyHandle = INVALID_TS_FILEHANDLE;
  116. }
  117. #endif
  118. return DrFile::Close();
  119. }