Source code of Windows XP (NT5)
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.

110 lines
2.5 KiB

  1. /*++
  2. Copyright (C) 2000-2001 Microsoft Corporation
  3. --*/
  4. #include <wbemcomn.h>
  5. #include "longstg.h"
  6. #include "absfile.h"
  7. DWORD CAbstractFile::Write(DWORD dwOffs, LPVOID pMem, DWORD dwBytes,
  8. DWORD *pdwWritten)
  9. {
  10. long lRes = m_pStage->WriteFile(m_nId, dwOffs, (BYTE*)pMem, dwBytes,
  11. pdwWritten);
  12. return lRes;
  13. }
  14. DWORD CAbstractFile::Read(DWORD dwOffs, LPVOID pMem, DWORD dwBytes,
  15. DWORD *pdwRead)
  16. {
  17. long lRes = m_pStage->ReadFile(m_nId, dwOffs, (BYTE*)pMem, dwBytes,
  18. pdwRead);
  19. return lRes;
  20. }
  21. DWORD CAbstractFile::SetFileLength(DWORD dwLen)
  22. {
  23. long lRes = m_pStage->SetFileLength(m_nId, dwLen);
  24. return lRes;
  25. }
  26. DWORD CAbstractFile::GetFileLength(DWORD* pdwLength)
  27. {
  28. long lRes = m_pStage->GetFileLength(m_nId, pdwLength);
  29. return lRes;
  30. }
  31. void CAbstractFile::Touch()
  32. {
  33. m_pStage->TouchTransaction();
  34. }
  35. long CAbstractFileSource::Create(LPCWSTR wszFileName, long lMaxFileSize,
  36. long lAbortTransactionFileSize)
  37. {
  38. m_Stage.SetMaxFileSize(lMaxFileSize, lAbortTransactionFileSize);
  39. return m_Stage.Create(wszFileName);
  40. }
  41. long CAbstractFileSource::Start()
  42. {
  43. return m_Stage.Initialize();
  44. }
  45. long CAbstractFileSource::Stop(DWORD dwShutDownFlags)
  46. {
  47. return m_Stage.Uninitialize(dwShutDownFlags);
  48. }
  49. DWORD CAbstractFileSource::Register(HANDLE hFile, int nID,
  50. bool bSupportsOverwrites,
  51. CAbstractFile **pFile)
  52. {
  53. long lRes = m_Stage.RegisterFile(nID, hFile, bSupportsOverwrites);
  54. if(lRes != ERROR_SUCCESS)
  55. return lRes;
  56. *pFile = new CAbstractFile(&m_Stage, nID);
  57. if(*pFile == NULL)
  58. return ERROR_OUTOFMEMORY;
  59. return ERROR_SUCCESS;
  60. }
  61. DWORD CAbstractFileSource::CloseAll()
  62. {
  63. long lRes = m_Stage.CloseAllFiles();
  64. if(lRes == ERROR_SUCCESS)
  65. return TRUE;
  66. else
  67. return FALSE;
  68. }
  69. DWORD CAbstractFileSource::Begin(DWORD *pdwTransId)
  70. {
  71. if(pdwTransId)
  72. *pdwTransId = 0;
  73. long lRes = m_Stage.BeginTransaction();
  74. return lRes;
  75. }
  76. DWORD CAbstractFileSource::Commit(DWORD dwTransId)
  77. {
  78. _ASSERT(dwTransId == 0, L"");
  79. long lRes = m_Stage.CommitTransaction();
  80. return lRes;
  81. }
  82. DWORD CAbstractFileSource::Rollback(DWORD dwTransId, bool* pbNonEmpty)
  83. {
  84. _ASSERT(dwTransId == 0, L"");
  85. long lRes = m_Stage.AbortTransaction(pbNonEmpty);
  86. return lRes;
  87. }
  88. void CAbstractFileSource::Dump(FILE* f)
  89. {
  90. m_Stage.Dump(f);
  91. }