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.

85 lines
1.4 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name :
  4. file.cpp
  5. Author :
  6. JoyC 11/10/1999
  7. Abstract:
  8. RDPDr File object handles mini-redirector specific file information
  9. Revision History:
  10. --*/
  11. #include "precomp.hxx"
  12. #define TRC_FILE "file"
  13. #include "trc.h"
  14. DrFile::DrFile(SmartPtr<DrDevice> &Device, ULONG FileId)
  15. {
  16. BEGIN_FN("DrFile");
  17. TRC_DBG((TB, "Create File Object %p for device %p",
  18. this, Device));
  19. SetClassName("DrFile");
  20. _Device = Device;
  21. _FileId = FileId;
  22. _Buffer = NULL;
  23. _BufferSize = 0;
  24. }
  25. DrFile::~DrFile()
  26. {
  27. BEGIN_FN("DrFile::~DrFile");
  28. TRC_DBG((TB, "Delete File Object %p for device %p",
  29. this, _Device));
  30. if (_Buffer) {
  31. delete _Buffer;
  32. }
  33. }
  34. PBYTE DrFile::AllocateBuffer(ULONG size)
  35. {
  36. BEGIN_FN("DrFile::AllocateBuffer")
  37. //
  38. // if _Buffer is not NULL, free it first
  39. //
  40. if (_Buffer) {
  41. delete _Buffer;
  42. }
  43. _Buffer = (PBYTE) new(NonPagedPool)BYTE[size];
  44. if (_Buffer) {
  45. _BufferSize = size;
  46. }
  47. else {
  48. _BufferSize = 0;
  49. }
  50. return _Buffer;
  51. }
  52. void DrFile::FreeBuffer()
  53. {
  54. BEGIN_FN("DrFile::FreeBuffer");
  55. if (_Buffer) {
  56. delete _Buffer;
  57. _Buffer = NULL;
  58. }
  59. _BufferSize = 0;
  60. }