如何通过Ant脚本了解驱动器可用空间

时间:2011-07-25 16:03:25

标签: ant

我们是否有可能通过Ant脚本知道任何驱动器的可用空间,因为我在部署ant脚本中复制了一个300mb大小的文件夹,因此我想在复制之前确认其中有超过300mb的空间驱动。

1 个答案:

答案 0 :(得分:4)

查看hasfreespace:http://ant.apache.org/manual/Tasks/conditions.html

<?xml version="1.0"?> 
<project name="test" default="test" basedir="."> 

     <target name="test" depends="exists,not-exists">  
          <echo message="Test target"/>
     </target>

     <target name="exists" if="space-exists">  
          <echo message="Space exists"/>
     </target>

     <target name="not-exists" unless="space-exists">  
          <echo message="Space does not exist"/>
     </target>

     <condition property="space-exists"> 
          <!-- Change this to 10000G to see it failing -->
          <hasfreespace partition="/" needed="1M"/>
     </condition>
</project>
相关问题