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.

basename.html 2.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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>Basename Task</title>
  6. </head>
  7. <body>
  8. <h2><a name="echo">Basename</a></h2>
  9. <h3>Description</h3>
  10. <p>
  11. Task to determine the basename of a specified file, optionally minus a
  12. specified suffix.
  13. </p>
  14. <p>
  15. When this task executes, it will set the specified property to the
  16. value of the last path element of the specified file. If <code>file</code> is a
  17. directory, the basename will be the last directory element. If
  18. <code>file</code> is a full-path, relative-path, or simple filename,
  19. the basename will be the simple file name, without any directory elements.
  20. </p>
  21. <p>
  22. <h3>Parameters</h3>
  23. <table border="1" cellpadding="2" cellspacing="0">
  24. <tr>
  25. <td valign="top"><b>Attribute</b></td>
  26. <td valign="top"><b>Description</b></td>
  27. <td align="center" valign="top"><b>Required</b></td>
  28. </tr>
  29. <tr>
  30. <td valign="top">file</td>
  31. <td valign="top">The path to take the basename of.</td>
  32. <td valign="top" align="center">Yes</td>
  33. </tr>
  34. <tr>
  35. <td valign="top">property</td>
  36. <td valign="top">The name of the property to set.</td>
  37. <td valign="top" align="center">Yes</td>
  38. </tr>
  39. <tr>
  40. <td valign="top">suffix</td>
  41. <td valign="top">The suffix to remove from the resulting basename
  42. (specified either with or without the &quot;<code>.</code>&quot;).</td>
  43. <td valign="top" align="center">No</td>
  44. </tr>
  45. </table>
  46. <h3>Examples</h3>
  47. <blockquote><pre>
  48. &lt;basename property=&quot;jar.filename&quot; file=&quot;${lib.jarfile}&quot;/&gt;
  49. </pre></blockquote>
  50. will set <code>jar.filename</code> to
  51. <code>myjar.jar</code>, if <code>lib.jarfile</code> is defined as either a
  52. full-path filename (eg., <code>/usr/local/lib/myjar.jar</code>),
  53. a relative-path filename (eg., <code>lib/myjar.jar</code>),
  54. or a simple filename (eg., <code>myjar.jar</code>).
  55. <blockquote><pre>
  56. &lt;basename property=&quot;cmdname&quot; file=&quot;D:/usr/local/foo.exe&quot;
  57. suffix=&quot;.exe&quot;/&gt;
  58. </pre></blockquote>
  59. will set <code>cmdname</code> to <code>foo</code>.
  60. <blockquote><pre>
  61. &lt;property environment=&quot;env&quot;/&gt;
  62. &lt;basename property=&quot;temp.dirname&quot; file=&quot;${env.TEMP}&quot;/&gt;
  63. </pre></blockquote>
  64. will set <code>temp.dirname</code> to the last directory element of
  65. the path defined for the <code>TEMP</code> environment variable.</p>
  66. <hr>
  67. <p align="center">Copyright &copy; 2002,2004-2005 The Apache Software Foundation.
  68. All rights Reserved.</p>
  69. </body>
  70. </html>