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.

188 lines
5.7 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2001, Microsoft Corporation All rights reserved.
  4. //
  5. // Module Name:
  6. //
  7. // file.h
  8. //
  9. // Abstract:
  10. //
  11. // This file contains the File layout object definition.
  12. //
  13. // Revision History:
  14. //
  15. // 2001-06-20 lguindon Created.
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #ifndef _FILE_H_
  19. #define _FILE_H_
  20. ///////////////////////////////////////////////////////////////////////////////
  21. //
  22. // Includes Files.
  23. //
  24. ///////////////////////////////////////////////////////////////////////////////
  25. // #include "infparser.h"
  26. ///////////////////////////////////////////////////////////////////////////////
  27. //
  28. // Class definition.
  29. //
  30. ///////////////////////////////////////////////////////////////////////////////
  31. class File
  32. {
  33. public:
  34. File(LPSTR sname, LPSTR destDir, LPSTR name, LPSTR srcDir, LPSTR srcName, INT dirId)
  35. {
  36. // Compute and copy destination directory.
  37. HRESULT hr;
  38. BOOL bSuccess = TRUE;
  39. switch(dirId)
  40. {
  41. case(10):
  42. {
  43. hr = StringCchCopyA(m_DestinationDir, ARRAYLEN(m_DestinationDir), destDir);
  44. if(!SUCCEEDED(hr)) {
  45. bSuccess = FALSE;
  46. }
  47. m_WindowsDir = TRUE;
  48. break;
  49. }
  50. case(11):
  51. {
  52. hr = StringCchPrintfA(m_DestinationDir , ARRAYLEN(m_DestinationDir), "System32\\%s",destDir);
  53. if(!SUCCEEDED(hr)) {
  54. bSuccess = FALSE;
  55. }
  56. m_WindowsDir = TRUE;
  57. break;
  58. }
  59. case(17):
  60. {
  61. hr = StringCchPrintfA(m_DestinationDir , ARRAYLEN(m_DestinationDir),"Inf\\%s",destDir);
  62. if(!SUCCEEDED(hr)) {
  63. bSuccess = FALSE;
  64. }
  65. m_WindowsDir = TRUE;
  66. break;
  67. }
  68. case(18):
  69. {
  70. hr = StringCchPrintfA(m_DestinationDir , ARRAYLEN(m_DestinationDir),"Help\\%s",destDir);
  71. if(!SUCCEEDED(hr)) {
  72. bSuccess = FALSE;
  73. }
  74. m_WindowsDir = TRUE;
  75. break;
  76. }
  77. case(24):
  78. {
  79. LPSTR index;
  80. index = strchr(destDir, '\\');
  81. hr = StringCchCopyA(m_DestinationDir, ARRAYLEN(m_DestinationDir), index + 1);
  82. if(!SUCCEEDED(hr)) {
  83. bSuccess = FALSE;
  84. }
  85. m_WindowsDir = FALSE;
  86. break;
  87. }
  88. case(25):
  89. {
  90. hr = StringCchCopyA(m_DestinationDir, ARRAYLEN(m_DestinationDir), destDir);
  91. if(!SUCCEEDED(hr)) {
  92. bSuccess = FALSE;
  93. }
  94. m_WindowsDir = TRUE;
  95. break;
  96. }
  97. default:
  98. {
  99. hr = StringCchCopyA(m_DestinationDir, ARRAYLEN(m_DestinationDir), destDir);
  100. if(!SUCCEEDED(hr)) {
  101. bSuccess = FALSE;
  102. }
  103. m_WindowsDir = FALSE;
  104. break;
  105. }
  106. }
  107. //
  108. // Verify that the last character of the destination dir is not '\'
  109. //
  110. if (m_DestinationDir[strlen(m_DestinationDir)-1] == '\\')
  111. {
  112. m_DestinationDir[strlen(m_DestinationDir)-1] = '\0';
  113. }
  114. // Copy the short destination file name
  115. hr = StringCchCopyA(m_ShortDestName, ARRAYLEN(m_ShortDestName), sname);
  116. if(!SUCCEEDED(hr)) {
  117. bSuccess = FALSE;
  118. }
  119. // Copy destination file name.
  120. hr = StringCchCopyA(m_DestinationName, ARRAYLEN(m_DestinationName), name);
  121. if(!SUCCEEDED(hr)) {
  122. bSuccess = FALSE;
  123. }
  124. // Copy source directory.
  125. hr = StringCchCopyA(m_SourceDir, ARRAYLEN(m_SourceDir), srcDir);
  126. if(!SUCCEEDED(hr)) {
  127. bSuccess = FALSE;
  128. }
  129. // Copy and correct source name.
  130. hr = StringCchCopyA(m_SourceName, ARRAYLEN(m_SourceName), srcName);
  131. if(!SUCCEEDED(hr)) {
  132. bSuccess = FALSE;
  133. }
  134. // if( m_SourceName[_tcslen(m_SourceName)-1] == '_')
  135. // {
  136. // m_SourceName[_tcslen(m_SourceName)-1] = 'I';
  137. // }
  138. // Initialize linked-list pointers.
  139. m_Next = NULL;
  140. m_Previous = NULL;
  141. if (!bSuccess) {
  142. printf("Error in File::File() \n");
  143. }
  144. };
  145. LPSTR getDirectoryDestination() { return(m_DestinationDir); };
  146. LPSTR getShortName() {/*printf("Shortname is %s\n", m_ShortDestName);*/ return (m_ShortDestName); } ;
  147. LPSTR getName() { return (m_DestinationName); };
  148. LPSTR getSrcDir() { return (m_SourceDir); };
  149. LPSTR getSrcName() { return (m_SourceName); };
  150. BOOL isWindowsDir() { return (m_WindowsDir);}
  151. File* getNext() { return (m_Next); };
  152. File* getPrevious() { return (m_Previous); };
  153. void setNext(File *next) { m_Next = next; };
  154. void setPrevious(File *previous) { m_Previous = previous; };
  155. private:
  156. CHAR m_ShortDestName[MAX_PATH];
  157. CHAR m_DestinationName[MAX_PATH];
  158. CHAR m_DestinationDir[MAX_PATH];
  159. CHAR m_SourceName[MAX_PATH];
  160. CHAR m_SourceDir[MAX_PATH];
  161. BOOL m_WindowsDir;
  162. File *m_Next;
  163. File *m_Previous;
  164. };
  165. #endif //_FILE_H_