Win32CDManager.cpp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. //----------------------------------------------------------------------------
  24. //
  25. // Westwood Studios Pacific.
  26. //
  27. // Confidential Information
  28. // Copyright (C) 2001 - All Rights Reserved
  29. //
  30. //----------------------------------------------------------------------------
  31. //
  32. // Project: Generals
  33. //
  34. // Module: Game Engine Device Win32 Common
  35. //
  36. // File name: Win32CDManager.cpp
  37. //
  38. // Created: 11/26/01 TR
  39. //
  40. //----------------------------------------------------------------------------
  41. //----------------------------------------------------------------------------
  42. // Includes
  43. //----------------------------------------------------------------------------
  44. #include "windows.h"
  45. #include "Common/GameMemory.h"
  46. #include "Common/FileSystem.h"
  47. #include "Win32DEvice/Common/Win32CDManager.h"
  48. //----------------------------------------------------------------------------
  49. // Externals
  50. //----------------------------------------------------------------------------
  51. //----------------------------------------------------------------------------
  52. // Defines
  53. //----------------------------------------------------------------------------
  54. //----------------------------------------------------------------------------
  55. // Private Types
  56. //----------------------------------------------------------------------------
  57. //----------------------------------------------------------------------------
  58. // Private Data
  59. //----------------------------------------------------------------------------
  60. //----------------------------------------------------------------------------
  61. // Public Data
  62. //----------------------------------------------------------------------------
  63. //----------------------------------------------------------------------------
  64. // Private Prototypes
  65. //----------------------------------------------------------------------------
  66. //----------------------------------------------------------------------------
  67. // Private Functions
  68. //----------------------------------------------------------------------------
  69. //----------------------------------------------------------------------------
  70. // Public Functions
  71. //----------------------------------------------------------------------------
  72. CDManagerInterface* CreateCDManager( void )
  73. {
  74. return NEW Win32CDManager;
  75. }
  76. //============================================================================
  77. // Win32CDDrive::Win32CDDrive
  78. //============================================================================
  79. Win32CDDrive::Win32CDDrive()
  80. {
  81. }
  82. //============================================================================
  83. // Win32CDDrive::~Win32CDDrive
  84. //============================================================================
  85. Win32CDDrive::~Win32CDDrive()
  86. {
  87. }
  88. //============================================================================
  89. // Win32CDDrive::refreshInfo
  90. //============================================================================
  91. void Win32CDDrive::refreshInfo( void )
  92. {
  93. Bool mayRequireUpdate = (m_disk != CD::NO_DISK);
  94. Char volName[1024];
  95. // read the volume info
  96. if ( GetVolumeInformation( m_drivePath.str(), volName, sizeof(volName) -1, NULL, NULL, NULL, NULL, 0 ))
  97. {
  98. m_diskName = volName;
  99. m_disk = CD::UNKNOWN_DISK;
  100. }
  101. else
  102. {
  103. m_diskName.clear();
  104. m_disk = CD::NO_DISK;
  105. if (mayRequireUpdate)
  106. TheFileSystem->unloadMusicFilesFromCD();
  107. }
  108. // This is an override, not an extension of CDDrive
  109. }
  110. //============================================================================
  111. // Win32CDManager::Win32CDManager
  112. //============================================================================
  113. Win32CDManager::Win32CDManager()
  114. {
  115. }
  116. //============================================================================
  117. // Win32CDManager::~Win32CDManager
  118. //============================================================================
  119. Win32CDManager::~Win32CDManager()
  120. {
  121. }
  122. //============================================================================
  123. // Win32CDManager::init
  124. //============================================================================
  125. void Win32CDManager::init( void )
  126. {
  127. CDManager::init(); // init base classes
  128. destroyAllDrives();
  129. // detect CD Drives
  130. for ( Char driveLetter = 'a'; driveLetter <= 'z'; driveLetter++ )
  131. {
  132. AsciiString drivePath;
  133. drivePath.format( "%c:\\", driveLetter );
  134. if ( GetDriveType( drivePath.str() ) == DRIVE_CDROM )
  135. {
  136. newDrive( drivePath.str() );
  137. }
  138. }
  139. refreshDrives();
  140. }
  141. //============================================================================
  142. // Win32CDManager::update
  143. //============================================================================
  144. void Win32CDManager::update( void )
  145. {
  146. CDManager::update();
  147. }
  148. //============================================================================
  149. // Win32CDManager::reset
  150. //============================================================================
  151. void Win32CDManager::reset( void )
  152. {
  153. CDManager::reset();
  154. }
  155. //============================================================================
  156. // Win32CDManager::createDrive
  157. //============================================================================
  158. CDDriveInterface* Win32CDManager::createDrive( void )
  159. {
  160. return NEW Win32CDDrive;
  161. }
  162. //============================================================================
  163. // Win32CDManager::refreshDrives
  164. //============================================================================
  165. void Win32CDManager::refreshDrives( void )
  166. {
  167. CDManager::refreshDrives();
  168. }