FileDocCategorySizeDatePackage
HasFreeSpace.javaAPI DocApache Ant 1.702774Wed Dec 13 06:16:26 GMT 2006org.apache.tools.ant.taskdefs.condition

HasFreeSpace

public class HasFreeSpace extends Object implements Condition
<hasfreespace>

Condition returns true if selected partition has the requested space, false otherwise.

since
Ant 1.7

Fields Summary
private String
partition
private String
needed
Constructors Summary
Methods Summary
public booleaneval()

        validate();
        try {
            if (JavaEnvUtils.isAtLeastJavaVersion("1.6")) {
                //reflection to avoid bootstrap/build problems
                File fs = new File(partition);
                ReflectWrapper w = new ReflectWrapper(fs);
                long free = ((Long)w.invoke("getFreeSpace")).longValue();
                return free >= StringUtils.parseHumanSizes(needed);
            } else {
                throw new BuildException("HasFreeSpace condition not supported on Java5 or less.");
            }
        } catch (Exception e) {
            throw new BuildException(e);
        }
    
public java.lang.StringgetNeeded()
The amount of free space required

return
the amount required

        return needed;
    
public java.lang.StringgetPartition()
The partition/device to check

return

        return partition;
    
public voidsetNeeded(java.lang.String needed)

        this.needed = needed;
    
public voidsetPartition(java.lang.String partition)

        this.partition = partition;
    
private voidvalidate()

        if(null == partition) {
            throw new BuildException("Please set the partition attribute.");
        }
        if(null == needed) {
            throw new BuildException("Please set the needed attribute.");
        }