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.4 KiB

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