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

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