git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277276 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -1,5 +1,5 @@ | |||
| /* | |||
| * Copyright 2000-2004 The Apache Software Foundation | |||
| * Copyright 2000-2005 The Apache Software Foundation | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| @@ -84,7 +84,7 @@ public class Copy extends Task { | |||
| * Copy task constructor. | |||
| */ | |||
| public Copy() { | |||
| fileUtils = FileUtils.newFileUtils(); | |||
| fileUtils = FileUtils.getFileUtils(); | |||
| granularity = fileUtils.getFileTimestampGranularity(); | |||
| } | |||
| @@ -1,5 +1,5 @@ | |||
| /* | |||
| * Copyright 2001-2002,2004 The Apache Software Foundation | |||
| * Copyright 2001-2005 The Apache Software Foundation | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| @@ -27,6 +27,7 @@ import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.condition.Os; | |||
| import org.apache.tools.ant.types.FileList; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Examines and removes out of date target files. If any of the target files | |||
| @@ -134,13 +135,10 @@ public class DependSet extends MatchingTask { | |||
| long now = (new Date()).getTime(); | |||
| /* | |||
| If we're on Windows, we have to munge the time up to 2 secs to | |||
| be able to check file modification times. | |||
| (Windows has a max resolution of two secs for modification times) | |||
| We have to munge the time to allow for the filesystem time | |||
| granularity. | |||
| */ | |||
| if (Os.isFamily("windows")) { | |||
| now += 2000; | |||
| } | |||
| now += FileUtils.getFileUtils().getFileTimestampGranularity(); | |||
| // | |||
| // Grab all the target files specified via filesets | |||
| @@ -1,5 +1,5 @@ | |||
| /* | |||
| * Copyright 2002-2004 The Apache Software Foundation | |||
| * Copyright 2002-2005 The Apache Software Foundation | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| @@ -27,6 +27,7 @@ import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.condition.Os; | |||
| import org.apache.tools.ant.types.EnumeratedAttribute; | |||
| import org.apache.tools.ant.types.Parameter; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Selector that chooses files based on their last modified date. | |||
| @@ -38,7 +39,7 @@ public class DateSelector extends BaseExtendSelector { | |||
| private long millis = -1; | |||
| private String dateTime = null; | |||
| private boolean includeDirs = false; | |||
| private int granularity = 0; | |||
| private long granularity = 0; | |||
| private int cmp = 2; | |||
| private String pattern; | |||
| /** Key to used for parameterized custom selector */ | |||
| @@ -59,9 +60,7 @@ public class DateSelector extends BaseExtendSelector { | |||
| * | |||
| */ | |||
| public DateSelector() { | |||
| if (Os.isFamily("dos")) { | |||
| granularity = 2000; | |||
| } | |||
| granularity = FileUtils.getFileUtils().getFileTimestampGranularity(); | |||
| } | |||
| /** | |||
| @@ -1,5 +1,5 @@ | |||
| /* | |||
| * Copyright 2000-2004 The Apache Software Foundation | |||
| * Copyright 2000-2005 The Apache Software Foundation | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| @@ -40,7 +40,7 @@ public abstract class MappingSelector extends BaseSelector { | |||
| * | |||
| */ | |||
| public MappingSelector() { | |||
| granularity = (int) FileUtils.newFileUtils().getFileTimestampGranularity(); | |||
| granularity = (int) FileUtils.getFileUtils().getFileTimestampGranularity(); | |||
| } | |||
| @@ -128,8 +128,8 @@ public abstract class MappingSelector extends BaseSelector { | |||
| /** | |||
| * Sets the number of milliseconds leeway we will give before we consider | |||
| * a file out of date. Defaults to 2000 on MS-DOS derivatives as the FAT | |||
| * file system. | |||
| * a file out of date. Defaults to 2000 on MS-DOS derivatives and 1000 on | |||
| * others. | |||
| * @param granularity the leeway in milliseconds | |||
| */ | |||
| public void setGranularity(int granularity) { | |||
| @@ -1,5 +1,5 @@ | |||
| /* | |||
| * Copyright 2001-2004 The Apache Software Foundation | |||
| * Copyright 2001-2005 The Apache Software Foundation | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| @@ -58,11 +58,14 @@ import org.apache.tools.ant.launch.Locator; | |||
| */ | |||
| public class FileUtils { | |||
| private static final FileUtils PRIMARY_INSTANCE = new FileUtils(); | |||
| //get some non-crypto-grade randomness from various places. | |||
| private static Random rand = new Random(System.currentTimeMillis() | |||
| + Runtime.getRuntime().freeMemory()); | |||
| private boolean onNetWare = Os.isFamily("netware"); | |||
| private static boolean onNetWare = Os.isFamily("netware"); | |||
| // for toURI | |||
| private static boolean[] isSpecial = new boolean[256]; | |||
| @@ -106,11 +109,21 @@ public class FileUtils { | |||
| * Factory method. | |||
| * | |||
| * @return a new instance of FileUtils. | |||
| * @deprecated Use getFileUtils instead, FileUtils do not have state. | |||
| */ | |||
| public static FileUtils newFileUtils() { | |||
| return new FileUtils(); | |||
| } | |||
| /** | |||
| * Method to retrieve The FileUtils, which is shared by all users of this | |||
| * method. | |||
| * @return an instance of FileUtils. | |||
| */ | |||
| public static FileUtils getFileUtils() { | |||
| return PRIMARY_INSTANCE; | |||
| } | |||
| /** | |||
| * Empty constructor. | |||
| */ | |||
| @@ -1356,7 +1369,6 @@ public class FileUtils { | |||
| return isUpToDate(sourceTime, destTime, getFileTimestampGranularity()); | |||
| } | |||
| /** | |||
| * close a writer without throwing any exception if something went wrong. | |||
| * Do not attempt to close it if the file is null | |||