You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

touch.html 4.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  5. <title>Touch Task</title>
  6. </head>
  7. <body>
  8. <h2><a name="touch">Touch</a></h2>
  9. <h3>Description</h3>
  10. <p>Changes the modification time of a resource and possibly creates it
  11. at the same time. In addition to working with a single file, this Task
  12. can also work on <a href="../CoreTypes/resource.html">resource</a> and
  13. resource collections (which also includes directories). Prior to Ant
  14. 1.7 only FileSet or <a href="../CoreTypes/filelist.html">Filelist</a>
  15. (since Ant 1.6) have been supported.</p>
  16. <h3>Parameters</h3>
  17. <table border="1" cellpadding="2" cellspacing="0">
  18. <tr>
  19. <td valign="top"><b>Attribute</b></td>
  20. <td valign="top"><b>Description</b></td>
  21. <td align="center" valign="top"><b>Required</b></td>
  22. </tr>
  23. <tr>
  24. <td valign="top">file</td>
  25. <td valign="top">The name of the file.</td>
  26. <td valign="top" align="center">Unless a nested resource collection element
  27. has been specified.</td>
  28. </tr>
  29. <tr>
  30. <td valign="top">millis</td>
  31. <td valign="top">Specifies the new modification time of the file
  32. in milliseconds since midnight Jan 1 1970.</td>
  33. <td valign="center" align="center" rowspan="2">No--datetime takes
  34. precedence, however if both are omitted the current time is assumed.</td>
  35. </tr>
  36. <tr>
  37. <td valign="top">datetime</td>
  38. <td valign="top">Specifies the new modification time of the file.</td>
  39. </tr>
  40. <tr>
  41. <td valign="top">pattern</td>
  42. <td valign="top">SimpleDateFormat-compatible pattern string.
  43. Defaults to MM/DD/YYYY HH:MM AM_or_PM or MM/DD/YYYY HH:MM:SS AM_or_PM.
  44. <b>Since Ant 1.6.3</b></td>
  45. <td valign="top" align="center">No</td>
  46. </tr>
  47. <tr>
  48. <td valign="top">mkdirs</td>
  49. <td valign="top">Whether to create nonexistent parent
  50. directories when touching new files. <b>Since Ant 1.6.3</b></td>
  51. <td valign="top" align="center">No, default <i>false</i>.</td>
  52. </tr>
  53. <tr>
  54. <td valign="top">verbose</td>
  55. <td valign="top">Whether to log the creation of new files.
  56. <b>Since Ant 1.6.3</b></td>
  57. <td valign="top" align="center">No, default <i>true</i>.</td>
  58. </tr>
  59. </table>
  60. <h3>Parameters specified as nested elements</h3>
  61. <h4>any resource collection</h4>
  62. <p>You can use any number of nested resource collection elements to
  63. define the resource for this task and refer to resources defined
  64. elsewhere. <b>Note:</b> resource passed to this task must implement
  65. the <code>org.apache.tools.ant.types.resources.Touchable</code>
  66. interface, this is true for all filesystem-based resources like those
  67. returned by path, fileset ot filelist.</p>
  68. <p>For backwards compatibility directories matched by nested filesets
  69. will be "touched" as well, use a &lt;type&gt; selector to suppress
  70. this. This only applies to filesets nested into the task directly,
  71. not to filesets nested into a path or any other resource
  72. collection.</p>
  73. <h4>mapper</h4>
  74. <p><em>Since Ant 1.6.3,</em> a nested <a href="../CoreTypes/mapper.html">
  75. mapper</a> can be specified. Files specified via nested
  76. <code>fileset</code>s, <code>filelist</code>s, or the <code>file</code>
  77. attribute are mapped using the specified mapper. For each file mapped,
  78. the resulting files are touched. If the original file exists its
  79. timestamp will be used. Otherwise the task settings (<code>millis</code>,
  80. <code>datetime</code>) take effect.</p>
  81. <h3>Examples</h3>
  82. <pre> &lt;touch file=&quot;myfile&quot;/&gt;</pre>
  83. <p>creates <code>myfile</code> if it doesn't exist and changes the
  84. modification time to the current time.</p>
  85. <pre> &lt;touch file=&quot;myfile&quot; datetime=&quot;06/28/2000 2:02 pm&quot;/&gt;</pre>
  86. <p>creates <code>myfile</code> if it doesn't exist and changes the
  87. modification time to Jun, 28 2000 2:02 pm (14:02 for those used to 24
  88. hour times).</p>
  89. <pre> &lt;touch datetime=&quot;09/10/1974 4:30 pm&quot;&gt;
  90. &lt;fileset dir=&quot;src_dir&quot;/&gt;
  91. &lt;/touch&gt;</pre>
  92. <p>changes the modification time to Oct, 09 1974 4:30 pm of all files and directories
  93. found in <code>src_dir</code>. </p>
  94. <pre> &lt;touch file=&quot;myfile&quot; datetime=&quot;06/28/2000 2:02:17 pm&quot;/&gt;</pre>
  95. <p>creates <code>myfile</code> if it doesn't exist and changes the
  96. modification time to Jun, 28 2000 2:02:17 pm (14:02:17 for those used to 24
  97. hour times), if the filesystem allows a precision of one second - a
  98. time close to it otherwise.</p>
  99. <pre> &lt;touch file=&quot;foo&quot;&gt;
  100. &lt;mapper type=&quot;glob&quot; from=&quot;foo&quot; to=&quot;bar&quot; /&gt;
  101. &lt;/touch&gt;
  102. </pre>
  103. <p>creates <code>bar</code> if it doesn't exist and changes the
  104. modification time to that of <code>foo</code>.</p>
  105. <hr>
  106. <p align="center">Copyright &copy; 2000-2001,2003-2005 The Apache Software Foundation. All rights
  107. Reserved.</p>
  108. </body>
  109. </html>