Browse Source

really say UNKNOWN if you don't know the size

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@349627 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 19 years ago
parent
commit
a6792f3fc5
1 changed files with 8 additions and 3 deletions
  1. +8
    -3
      src/main/org/apache/tools/ant/types/Resource.java

+ 8
- 3
src/main/org/apache/tools/ant/types/Resource.java View File

@@ -39,6 +39,9 @@ public class Resource extends DataType
/** Constant unknown size */
public static final long UNKNOWN_SIZE = -1;

/** Constant unknown datetime for getLastModified */
public static final long UNKNOWN_DATETIME = 0L;

/** Magic number */
protected static final int MAGIC = getMagicNumber("Resource".getBytes());

@@ -181,10 +184,10 @@ public class Resource extends DataType
return ((Resource) getCheckedRef()).getLastModified();
}
if (!isExists() || lastmodified == null) {
return 0L;
return UNKNOWN_DATETIME;
}
long result = lastmodified.longValue();
return result < 0L ? 0L : result;
return result < UNKNOWN_DATETIME ? UNKNOWN_DATETIME : result;
}

/**
@@ -237,7 +240,9 @@ public class Resource extends DataType
if (isReference()) {
return ((Resource) getCheckedRef()).getSize();
}
return isExists() && size != null ? size.longValue() : 0L;
return isExists() ?
(size != null ? size.longValue() : UNKNOWN_SIZE)
: 0L;
}

/**


Loading…
Cancel
Save