harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lian...@apache.org
Subject svn commit: r505213 - in /harmony/enhanced/classlib/trunk/modules: luni/src/test/java/tests/api/java/io/FileTest.java portlib/src/main/native/port/windows/hyfile.c
Date Fri, 09 Feb 2007 08:18:09 GMT
Author: liangyx
Date: Fri Feb  9 00:18:09 2007
New Revision: 505213

URL: http://svn.apache.org/viewvc?view=rev&rev=505213
Log:
Apply patch for HARMONY-2146([classlib][io] java.io.File.lastModified() returns wrong value)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java?view=diff&rev=505213&r1=505212&r2=505213
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java
Fri Feb  9 00:18:09 2007
@@ -1156,6 +1156,10 @@
 			assertTrue("LastModified Time Incorrect: " + lastModifiedTime,
 					lastModifiedTime == 315550800000L);
 			f.delete();
+            
+            // Regression for Harmony-2146
+            f = new File("/../");
+            assertTrue(f.lastModified() > 0);
 		} catch (IOException e) {
 			fail("Unexpected IOException during test : " + e.getMessage());
 		}

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c?view=diff&rev=505213&r1=505212&r2=505213
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c
Fri Feb  9 00:18:09 2007
@@ -254,37 +254,46 @@
 I_64 VMCALL
 hyfile_lastmod (struct HyPortLibrary * portLibrary, const char *path)
 {
-  WIN32_FIND_DATA myStat;
-  HANDLE newHandle;
-  I_64 result, tempResult;
-  I_32 error;
+    FILETIME lastWriteTime;
+    HANDLE newHandle;
+    I_64 result, tempResult;
+    I_32 error;
 
-  newHandle = FindFirstFile (path, &myStat);
-  if (newHandle == INVALID_HANDLE_VALUE)
+    newHandle = CreateFile(path, FILE_READ_ATTRIBUTES,  
+        FILE_SHARE_READ,  
+        NULL,  
+        OPEN_EXISTING,  
+        FILE_FLAG_BACKUP_SEMANTICS,  
+        NULL);
+    if (newHandle == INVALID_HANDLE_VALUE)
     {
-      error = GetLastError ();
-      portLibrary->error_set_last_error (portLibrary, error,
-					 findError (error));
-      return -1;
+        error = GetLastError ();
+        portLibrary->error_set_last_error (portLibrary, error,
+            findError (error));
+        return -1;
     }
 
-  /*
-   * Search MSDN for 'Converting a time_t Value to a File Time' for following implementation.
-   */
-  tempResult =
-    ((I_64) myStat.ftLastWriteTime.
-     dwHighDateTime << (I_64) 32) | (I_64) myStat.ftLastWriteTime.
-    dwLowDateTime;
+    if (0 == GetFileTime(newHandle, NULL, NULL, &lastWriteTime)) {
+        error = GetLastError ();          
+    	portLibrary->error_set_last_error (portLibrary, error,
+			findError (error));
+		return -1;
+	}
 
-  result = (tempResult - 116444736000000000) / 10000;
+    /*
+    * Search MSDN for 'Converting a time_t Value to a File Time' for following implementation.
+    */
+    tempResult =
+        ((I_64) lastWriteTime.dwHighDateTime << (I_64) 32) | (I_64) lastWriteTime.dwLowDateTime;
+	result = (tempResult - 116444736000000000) / 10000;
 
-  if (0 == FindClose (newHandle))
+    if (0 == CloseHandle (newHandle))
     {
-      error = GetLastError ();
-      portLibrary->error_set_last_error (portLibrary, error, findError (error));	/* continue
*/
+        error = GetLastError ();
+        portLibrary->error_set_last_error (portLibrary, error, findError (error));   
/* continue */
     }
 
-  return result;
+    return result;
 }
 
 #undef CDEV_CURRENT_FUNCTION



Mime
View raw message