Move constant about minimum file timestamp resolution into FileUtils
authorEd Swartz <ed.swartz@nokia.com>
Fri, 04 Dec 2009 14:51:45 -0600
changeset 634 baa31ffa93b5
parent 633 1bb6b7462d64
child 635 91399e4af0cf
Move constant about minimum file timestamp resolution into FileUtils
core/com.nokia.cpp.utils.core/src/com/nokia/cpp/internal/api/utils/core/FileUtils.java
project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestViewDataCache.java
project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ViewDataCache.java
--- a/core/com.nokia.cpp.utils.core/src/com/nokia/cpp/internal/api/utils/core/FileUtils.java	Fri Dec 04 14:46:25 2009 -0600
+++ b/core/com.nokia.cpp.utils.core/src/com/nokia/cpp/internal/api/utils/core/FileUtils.java	Fri Dec 04 14:51:45 2009 -0600
@@ -297,7 +297,8 @@
      * the workspace via links (very slow)
      * @return new path (workspace-relative) or null if not resolvable to workspace
      */
-    static public IPath convertToWorkspacePath(IPath cpath, boolean makeCanonical, boolean resolveLinks) {
+    @SuppressWarnings("deprecation")
+	static public IPath convertToWorkspacePath(IPath cpath, boolean makeCanonical, boolean resolveLinks) {
         if (!Platform.isRunning() || cpath == null)
             return null;
         
@@ -883,4 +884,20 @@
 	private static IStatus createErrorStatus(Exception e) {
 		return new Status(IStatus.ERROR, UtilsCorePlugin.ID, null, e);
 	}
+	
+	/**
+	 * Get the minimum timestamp resolution for a file in ms (based on heuristics for the OS).
+	 * @param path path to file of interest, or <code>null</code> for worst case
+	 * @return number of ms of resolution.  E.g., 50 means only changes in 50ms increments are stored
+	 */
+	public static long getMinimumFileTimestampResolution(IPath path) {
+		// VFAT on Win32 uses 2 second increments.  Linux ext2/3 uses 1 second resolution,
+		// until ext4, where it becomes nanoseconds.
+		// Assume the worst format in all cases.
+		long res = HostOS.IS_WIN32 ? 2000 : 1000;
+		if (path != null) {
+			// todo
+		}
+		return res;
+	}
 }
--- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestViewDataCache.java	Fri Dec 04 14:46:25 2009 -0600
+++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestViewDataCache.java	Fri Dec 04 14:51:45 2009 -0600
@@ -61,7 +61,7 @@
 	private File projectDir;
 
 	// Try to wait long enough to ensure the timestamp-based check will detect a change
-	private static final long FS_TIME_RESOLUTION = ViewDataCache.ModelFileTimestampCollection.MIN_TIMESTAMP_RESOLUTION;
+	private static final long FS_TIME_RESOLUTION = FileUtils.getMinimumFileTimestampResolution(null);
 	
 	/* (non-Javadoc)
 	 * @see com.nokia.carbide.cpp.epoc.engine.tests.BaseTest#setUp()
--- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ViewDataCache.java	Fri Dec 04 14:46:25 2009 -0600
+++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ViewDataCache.java	Fri Dec 04 14:51:45 2009 -0600
@@ -218,13 +218,6 @@
 	
 	public static class ModelFileTimestampCollection {
 		/**
-		 * The minimum timestamp resolution for a file in ms (based on heuristics for the OS).
-		 * VFAT on Win32 uses 2 second increments.  Linux ext2/3 uses 1 second resolution, 
-		 * until ext4, where it becomes nanoseconds.
-		 * Assume the worst format in all cases.
-		 */
-		public static final long MIN_TIMESTAMP_RESOLUTION = HostOS.IS_WIN32 ? 2000 : 1000;
-		/**
 		 * Delay in ms between successive checks of the filesystem, to avoid wasting time
 		 * when such checks are slow, and in cases where it's unlikely the human will edit files
 		 * fast enough to care.
@@ -424,6 +417,7 @@
 	 * @return
 	 * @throws CoreException
 	 */
+	@SuppressWarnings("unchecked")
 	private Data getViewData(IPath modelPath, IViewConfiguration configuration,
 			ViewConfigState state, ViewConfigKey key) throws CoreException {
 		Data data;