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.

attrib.html 5.6 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <!DOCTYPE html>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. https://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <html lang="en">
  17. <head>
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>Apache Ant User Manual</title>
  20. </head>
  21. <body>
  22. <h2 id="attrib">Attrib</h2>
  23. <p><em>Since Apache Ant 1.6</em>.</p>
  24. <h3>Description</h3>
  25. <p>Changes the attributes of a file or all files inside specified directories. Right now it has
  26. effect only under Windows. Each of the 4 possible permissions has its own attribute, matching the
  27. arguments for the attrib command.</p>
  28. <p><a href="../Types/fileset.html">FileSet</a>s, <a href="../Types/dirset.html">DirSet</a>s
  29. or <a href="../Types/filelist.html">FileList</a>s can be specified using
  30. nested <code>&lt;fileset&gt;</code>, <code>&lt;dirset&gt;</code> and <code>&lt;filelist&gt;</code>
  31. elements.</p>
  32. <p><em>Since Ant 1.7</em>, this task supports
  33. arbitrary <a href="../Types/resources.html#collection">resource collections</a> as nested
  34. elements.</p>
  35. <!--p>By default this task will use a single invocation of the underlying
  36. attrib command. If you are working on a large number of files this
  37. may result in a command line that is too long for your operating
  38. system. If you encounter such problems, you should set the
  39. maxparallel attribute of this task to a non-zero value. The number to
  40. use highly depends on the length of your file names (the depth of your
  41. directory tree), so you'll have to experiment a little.</p-->
  42. <p>By default this task won't do anything unless it detects it is running on a Windows system. If
  43. you know for sure that you have a <code>attrib</code> executable on your <code>PATH</code> that is
  44. command line compatible with the Windows command, you can use the task's <var>os</var> attribute and
  45. set its value to your current OS.</p>
  46. <p>See the <a href="setpermissions.html">setpermissions</a> task for a platform independent
  47. alternative.</p>
  48. <h3>Parameters</h3>
  49. <table class="attr">
  50. <tr>
  51. <th scope="col">Attribute</th>
  52. <th scope="col">Description</th>
  53. <th scope="col">Required</th>
  54. </tr>
  55. <tr>
  56. <td>file</td>
  57. <td>the file or directory of which the permissions must be changed.</td>
  58. <td>Yes, or nested <code>&lt;fileset/list&gt;</code> elements</td>
  59. </tr>
  60. <tr>
  61. <td>readonly</td>
  62. <td>the readonly permission.</td>
  63. <td rowspan="4">At least one of the four</td>
  64. </tr>
  65. <tr>
  66. <td>archive</td>
  67. <td class="left">the archive permission.</td>
  68. </tr>
  69. <tr>
  70. <td>system</td>
  71. <td class="left">the system permission.</td>
  72. </tr>
  73. <tr>
  74. <td>hidden</td>
  75. <td class="left">the hidden permission.</td>
  76. </tr>
  77. <tr>
  78. <td>type</td>
  79. <td>One of <q>file</q>, <q>dir</q> or <q>both</q>. If set to <q>file</q>, only the permissions
  80. of plain files are going to be changed. If set to <q>dir</q>, only the directories are
  81. considered.<br/>
  82. <strong>Note</strong>: The type attribute does not apply to
  83. nested <code>dirset</code>s&mdash;<code>dirset</code>s always implicitly assume type to
  84. be <q>dir</q>.</td>
  85. <td>No; default is <q>file</q></td>
  86. </tr>
  87. <tr>
  88. <td>verbose</td>
  89. <td>Whether to print a summary after execution or not.</td>
  90. <td>No; defaults to <q>false</q></td>
  91. </tr>
  92. <!--tr>
  93. <td>parallel</td>
  94. <td>process all specified files using a single
  95. <kbd>chmod</kbd> command.</td>
  96. <td>No; defaults to <q>true</q></td>
  97. </tr>
  98. <tr>
  99. <td>maxparallel</td>
  100. <td>Limit the amount of parallelism by passing at
  101. most this many sourcefiles at once. Set it to negative integer for
  102. unlimited. <em>Since Ant 1.6</em>.</td>
  103. <td>No, defaults to unlimited</td>
  104. </tr-->
  105. <tr>
  106. <td>os</td>
  107. <td>list of Operating Systems on which the command may be executed.</td>
  108. <td>No</td>
  109. </tr>
  110. <tr>
  111. <td>osfamily</td>
  112. <td>OS family as used in the <a href="../Tasks/conditions.html#os">&lt;os&gt;</a>
  113. condition.</td>
  114. <td>No; defaults to <q>windows</q></td>
  115. </tr>
  116. </table>
  117. <h3>Examples</h3>
  118. <p>Make the <code>run.bat</code> file read-only and hidden.</p>
  119. <pre>&lt;attrib file=&quot;${dist}/run.bat&quot; readonly=&quot;true&quot; hidden=&quot;true&quot;/&gt;</pre>
  120. <p>Make all <samp>.xml</samp> files below <samp>${meta.inf}</samp> readable.</p>
  121. <pre>&lt;attrib readonly=&quot;false&quot;&gt;
  122. &lt;fileset dir=&quot;${meta.inf}&quot; includes=&quot;**/*.xml&quot;/&gt;
  123. &lt;/attrib&gt;</pre>
  124. <p>Make all files below <samp>shared/sources1</samp> (except those below any directory
  125. named <samp>trial</samp>) read-only and archived. In addition all files belonging to a FileSet
  126. with <var>id</var> <samp>other.shared.sources</samp> get the same attributes.</p>
  127. <pre>
  128. &lt;attrib readonly=&quot;true&quot; archive=&quot;true&quot;&gt;
  129. &lt;fileset dir=&quot;shared/sources1&quot;&gt;
  130. &lt;exclude name=&quot;**/trial/**&quot;/&gt;
  131. &lt;/fileset&gt;
  132. &lt;fileset refid=&quot;other.shared.sources&quot;/&gt;
  133. &lt;/attrib&gt;</pre>
  134. </body>
  135. </html>