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.

366 lines
8.7 KiB

  1. /*++
  2. Copyright (c) 1990-2001 Microsoft Corporation
  3. Module Name:
  4. XCopy.hxx
  5. Abstract:
  6. This module contains the definition for the XCOPY class, which
  7. implements the DOS5-compatible XCopy utility.
  8. Author:
  9. Ramon Juan San Andres (ramonsa) 01-May-1990
  10. Revision History:
  11. --*/
  12. #if !defined( _XCOPY_ )
  13. #define _XCOPY_
  14. #include "object.hxx"
  15. #include "keyboard.hxx"
  16. #include "program.hxx"
  17. //
  18. // Forward references
  19. //
  20. DECLARE_CLASS( ARRAY );
  21. DECLARE_CLASS( FSN_DIRECTORY );
  22. DECLARE_CLASS( FSNODE );
  23. DECLARE_CLASS( FSN_FILE );
  24. DECLARE_CLASS( FSN_FILTER );
  25. DECLARE_CLASS( TIMEINFO );
  26. DECLARE_CLASS( XCOPY );
  27. DECLARE_CLASS( ARGUMENT_LEXEMIZER );
  28. DECLARE_CLASS( STRING_ARRAY );
  29. DECLARE_CLASS( ITERATOR );
  30. class XCOPY : public PROGRAM {
  31. public:
  32. DECLARE_CONSTRUCTOR( XCOPY );
  33. NONVIRTUAL
  34. ~XCOPY (
  35. );
  36. NONVIRTUAL
  37. BOOLEAN
  38. Initialize (
  39. );
  40. NONVIRTUAL
  41. BOOLEAN
  42. DoCopy (
  43. );
  44. NONVIRTUAL
  45. VOID
  46. DisplayMessageAndExit (
  47. IN MSGID MsgId,
  48. IN PWSTRING String,
  49. IN ULONG ExitCode
  50. );
  51. private:
  52. NONVIRTUAL
  53. VOID
  54. Construct (
  55. );
  56. NONVIRTUAL
  57. VOID
  58. AbortIfCtrlC(
  59. VOID
  60. );
  61. NONVIRTUAL
  62. PFSN_DIRECTORY
  63. MakeDirectory(
  64. IN PPATH DestinationPath,
  65. IN PCPATH TemplatePath
  66. );
  67. NONVIRTUAL
  68. BOOLEAN
  69. CheckTargetSpace (
  70. IN OUT PFSN_FILE File,
  71. IN PPATH DestinationPath
  72. );
  73. NONVIRTUAL
  74. VOID
  75. CheckArgumentConsistency (
  76. );
  77. NONVIRTUAL
  78. BOOLEAN
  79. Copier (
  80. IN OUT PFSN_FILE File,
  81. IN PPATH DestinationPath
  82. );
  83. NONVIRTUAL
  84. VOID
  85. DeallocateThings (
  86. );
  87. NONVIRTUAL
  88. VOID
  89. ExitWithError(
  90. IN DWORD ErrorCode
  91. );
  92. NONVIRTUAL
  93. VOID
  94. GetArgumentsCmd(
  95. );
  96. NONVIRTUAL
  97. VOID
  98. GetDirectoryAndFilePattern(
  99. IN PPATH Path,
  100. IN BOOLEAN CopyingManyFiles,
  101. OUT PPATH *OutDirectory,
  102. OUT PWSTRING *OutFilePattern
  103. );
  104. NONVIRTUAL
  105. VOID
  106. GetDirectoryAndFilters(
  107. IN PPATH Path,
  108. OUT PFSN_DIRECTORY *OutDirectory,
  109. OUT PFSN_FILTER *FileFilter,
  110. OUT PFSN_FILTER *DirectoryFilter,
  111. OUT PBOOLEAN CopyingManyFiles
  112. );
  113. NONVIRTUAL
  114. VOID
  115. InitializeThings (
  116. );
  117. NONVIRTUAL
  118. BOOL
  119. IsCyclicalCopy(
  120. IN PPATH PathSrc,
  121. IN PPATH PathTrg
  122. );
  123. NONVIRTUAL
  124. BOOL
  125. IsFileName(
  126. IN PPATH Path,
  127. IN BOOLEAN CopyingManyFiles
  128. );
  129. NONVIRTUAL
  130. PARGUMENT_LEXEMIZER
  131. ParseArguments(
  132. IN PWSTRING CmdLine,
  133. OUT PARRAY ArgArray
  134. );
  135. STATIC
  136. WINAPI
  137. ProgressCallBack(
  138. LARGE_INTEGER TotalFileSize,
  139. LARGE_INTEGER TotalBytesTransferred,
  140. LARGE_INTEGER StreamSize,
  141. LARGE_INTEGER StreamBytesTransferred,
  142. DWORD dwStreamNumber,
  143. DWORD dwCallbackReason,
  144. HANDLE hSourceFile,
  145. HANDLE hDestinationFile,
  146. LPVOID lpData OPTIONAL
  147. );
  148. NONVIRTUAL
  149. PWSTRING
  150. QueryMessageString (
  151. IN MSGID MsgId
  152. );
  153. VOID
  154. SetArguments(
  155. );
  156. NONVIRTUAL
  157. BOOLEAN
  158. Traverse (
  159. IN PFSN_DIRECTORY Directory,
  160. IN OUT PPATH DestinationPath,
  161. IN PFSN_FILTER FileFilter,
  162. IN PFSN_FILTER DirectoryFilter,
  163. IN BOOLEAN CopyDirectoryStreams
  164. );
  165. NONVIRTUAL
  166. BOOLEAN
  167. UpdateTraverse (
  168. IN PFSN_DIRECTORY Directory,
  169. IN OUT PPATH DestinationPath,
  170. IN PFSN_FILTER FileFilter,
  171. IN PFSN_FILTER DirectoryFilter,
  172. IN BOOLEAN CopyDirectoryStreams
  173. );
  174. NONVIRTUAL
  175. BOOLEAN
  176. UserConfirmedCopy (
  177. IN PCWSTRING SourcePath,
  178. IN PCWSTRING DestinationPath
  179. );
  180. NONVIRTUAL
  181. BOOLEAN
  182. UserConfirmedOverWrite (
  183. IN PPATH DestinationFile
  184. );
  185. NONVIRTUAL
  186. BOOLEAN
  187. InitializeExclusionList(
  188. IN PWSTRING ListOfFiles
  189. );
  190. NONVIRTUAL
  191. BOOLEAN
  192. AddToExclusionList(
  193. IN PWSTRING ExclusionListFileName
  194. );
  195. NONVIRTUAL
  196. BOOLEAN
  197. IsExcluded(
  198. IN PCPATH Path
  199. );
  200. NONVIRTUAL
  201. BOOLEAN
  202. QueryOverWriteSwitch(
  203. );
  204. //
  205. // Paths, switches etc. specified in the command line.
  206. //
  207. //
  208. // DOS options
  209. //
  210. PPATH _SourcePath;
  211. PPATH _DestinationPath;
  212. PTIMEINFO _Date;
  213. BOOLEAN _ArchiveSwitch;
  214. BOOLEAN _EmptySwitch;
  215. BOOLEAN _ModifySwitch;
  216. BOOLEAN _PromptSwitch;
  217. BOOLEAN _SubdirSwitch;
  218. BOOLEAN _VerifySwitch;
  219. BOOLEAN _WaitSwitch;
  220. //
  221. // Windows NT additional options
  222. //
  223. BOOLEAN _OverWriteSwitch; // Prompt on overwrite
  224. BOOLEAN _ContinueSwitch; // Continue if error
  225. BOOLEAN _CopyIfOldSwitch; // Only newer files
  226. BOOLEAN _DecryptSwitch; // Destination file un-encrypt
  227. BOOLEAN _IntelligentSwitch; // Don't ask F or D
  228. BOOLEAN _HiddenSwitch; // Copy hidden
  229. BOOLEAN _ReadOnlySwitch; // Overwrite RO
  230. BOOLEAN _SilentSwitch; // Silent mode
  231. BOOLEAN _VerboseSwitch; // Verbose mode
  232. BOOLEAN _DontCopySwitch; // Display only
  233. BOOLEAN _StructureOnlySwitch; // Structure only
  234. BOOLEAN _UpdateSwitch; // Apdate existing
  235. BOOLEAN _CopyAttrSwitch; // Copy attributes
  236. BOOLEAN _UseShortSwitch; // Use short names
  237. BOOLEAN _RestartableSwitch; // Copy is restartable
  238. BOOLEAN _OwnerSwitch; // Copy owner + ACL
  239. BOOLEAN _AuditSwitch; // Copy SACL
  240. //
  241. // Are we copying to diskette?
  242. //
  243. BOOLEAN _DisketteCopy;
  244. //
  245. // Number of files copied.
  246. //
  247. ULONG _FilesCopied;
  248. //
  249. // Keyboard
  250. //
  251. PKEYBOARD _Keyboard;
  252. //
  253. // Destination file specification. Used to convert source file
  254. // names to destination file names.
  255. //
  256. PWSTRING _FileNamePattern;
  257. //
  258. // Indicates if it is ok to remove empty directories.
  259. //
  260. BOOLEAN _CanRemoveEmptyDirectories;
  261. //
  262. // Indicate if the destination is a file, and what the target
  263. // file name should be.
  264. //
  265. BOOLEAN _TargetIsFile;
  266. PPATH _TargetPath;
  267. // File name with the exclusion list.
  268. //
  269. PSTRING_ARRAY _ExclusionList;
  270. PITERATOR _Iterator;
  271. BOOLEAN _Cancelled;
  272. };
  273. INLINE
  274. VOID
  275. XCOPY::AbortIfCtrlC (
  276. VOID
  277. )
  278. /*++
  279. Routine Description:
  280. Aborts the program if Ctrl-C was hit.
  281. Arguments:
  282. None.
  283. Return Value:
  284. None.
  285. Notes:
  286. --*/
  287. {
  288. if ( _Keyboard->GotABreak() ) {
  289. exit( EXIT_TERMINATED );
  290. }
  291. }
  292. #endif // _XCOPY_