Browse Source

magicnumbers

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@579953 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
ac16a45be3
2 changed files with 8 additions and 3 deletions
  1. +6
    -3
      src/main/org/apache/tools/ant/util/FileUtils.java
  2. +2
    -0
      src/main/org/apache/tools/ant/util/UUEncoder.java

+ 6
- 3
src/main/org/apache/tools/ant/util/FileUtils.java View File

@@ -54,7 +54,7 @@ import org.apache.tools.ant.types.resources.FileResource;
*
*/
public class FileUtils {
private static final int EXPAND_SPACE = 50;
private static final FileUtils PRIMARY_INSTANCE = new FileUtils();

//get some non-crypto-grade randomness from various places.
@@ -578,9 +578,11 @@ public class FileUtils {
return (c == sep);
}
if (c == sep) {
// CheckStyle:MagicNumber OFF
if (!(ON_DOS && len > 4 && filename.charAt(1) == sep)) {
return false;
}
// CheckStyle:MagicNumber ON
int nextsep = filename.indexOf(sep, 2);
return nextsep > 2 && nextsep + 1 < len;
}
@@ -611,7 +613,7 @@ public class FileUtils {
if (toProcess == null || toProcess.length() == 0) {
return "";
}
StringBuffer path = new StringBuffer(toProcess.length() + 50);
StringBuffer path = new StringBuffer(toProcess.length() + EXPAND_SPACE);
PathTokenizer tokenizer = new PathTokenizer(toProcess);
while (tokenizer.hasMoreTokens()) {
String pathComponent = tokenizer.nextToken();
@@ -740,9 +742,10 @@ public class FileUtils {
String name = f.getName();
boolean isAbsolute = path.charAt(0) == File.separatorChar;
// treat directories specified using .DIR syntax as files
// CheckStyle:MagicNumber OFF
boolean isDirectory = f.isDirectory()
&& !name.regionMatches(true, name.length() - 4, ".DIR", 0, 4);
// CheckStyle:MagicNumber ON
String device = null;
StringBuffer directory = null;
String file = null;


+ 2
- 0
src/main/org/apache/tools/ant/util/UUEncoder.java View File

@@ -109,7 +109,9 @@ public class UUEncoder {
byte[] data, int offset, int length, OutputStream out)
throws IOException {
// write out the number of characters encoded in this line.
// CheckStyle:MagicNumber OFF
out.write((byte) ((length & 0x3F) + ' '));
// CheckStyle:MagicNumber ON
byte a;
byte b;
byte c;


Loading…
Cancel
Save