Revision: 5914
          http://jnode.svn.sourceforge.net/jnode/?rev=5914&view=rev
Author:   galatnm
Date:     2012-08-10 06:44:27 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Improve HFS+ date extraction

Modified Paths:
--------------
    trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java
    trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java
    trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java

Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java      2012-08-10 
06:41:36 UTC (rev 5913)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java      2012-08-10 
06:44:27 UTC (rev 5914)
@@ -17,11 +17,10 @@
  * along with this library; If not, write to the Free Software Foundation, 
Inc., 
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
- 
+
 package org.jnode.fs.hfsplus;
 
 import java.io.IOException;
-
 import org.jnode.fs.FSAccessRights;
 import org.jnode.fs.FSDirectory;
 import org.jnode.fs.FSEntry;
@@ -44,10 +43,9 @@
     protected boolean valid;
     protected boolean dirty;
     protected FSAccessRights rights;
-    private long lastModified;
 
     /**
-     * 
+     *
      * @param fs
      * @param parent
      * @param name
@@ -61,7 +59,6 @@
         this.record = record;
         this.type = getFSEntryType();
         this.rights = new UnixFSAccessRights(fs);
-        this.lastModified = System.currentTimeMillis();
     }
 
     private int getFSEntryType() {
@@ -100,8 +97,14 @@
 
     @Override
     public long getLastModified() throws IOException {
-        // TODO Auto-generated method stub
-        return lastModified;
+        if (isFile()) {
+            CatalogFile catalogFile = new CatalogFile(getData());
+            return catalogFile.getContentModDate();
+        }
+        else {
+            CatalogFolder catalogFolder = new CatalogFolder(getData());
+            return catalogFolder.getContentModDate();
+        }
     }
 
     @Override
@@ -139,7 +142,15 @@
 
     @Override
     public void setLastModified(long lastModified) throws IOException {
-        this.lastModified = lastModified;
+        if (isFile()) {
+            CatalogFile catalogFile = new CatalogFile(getData());
+            // catalogFile.setContentModDate();
+            throw new UnsupportedOperationException("Not implemented yet.");
+        }
+        else {
+            CatalogFolder catalogFolder = new CatalogFolder(getData());
+            catalogFolder.setContentModDate(lastModified);
+        }
     }
 
     @Override
@@ -168,4 +179,14 @@
         return this.record.getData();
     }
 
+    public long getCreated() throws IOException {
+        if (isFile()) {
+            CatalogFile catalogFile = new CatalogFile(getData());
+            return catalogFile.getCreateDate();
+        }
+        else {
+            CatalogFolder catalogFolder = new CatalogFolder(getData());
+            return catalogFolder.getCreateDate();
+        }
+    }
 }

Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java       
2012-08-10 06:41:36 UTC (rev 5913)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java       
2012-08-10 06:44:27 UTC (rev 5914)
@@ -137,12 +137,12 @@
         return fileId;
     }
 
-    public int getCreateDate() {
-        return createDate;
+    public long getCreateDate() {
+        return HfsUtils.getDate(createDate & 0xffffffffL, false) * 1000L;
     }
 
-    public int getContentModDate() {
-        return contentModDate;
+    public long getContentModDate() {
+        return HfsUtils.getDate(contentModDate & 0xffffffffL, false) * 1000L;
     }
 
     public int getAttrModDate() {

Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java     
2012-08-10 06:41:36 UTC (rev 5913)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java     
2012-08-10 06:44:27 UTC (rev 5914)
@@ -112,12 +112,12 @@
         return folderId;
     }
 
-    public int getCreateDate() {
-        return createDate;
+    public long getCreateDate() {
+        return HfsUtils.getDate(createDate & 0xffffffffL, false) * 1000L;
     }
 
-    public int getContentModDate() {
-        return contentModDate;
+    public long getContentModDate() {
+        return HfsUtils.getDate(contentModDate & 0xffffffffL, false) * 1000L;
     }
 
     public int getAttrModDate() {
@@ -136,12 +136,12 @@
         this.folderId = folderId;
     }
 
-    public void setCreateDate(int createDate) {
-        this.createDate = createDate;
+    public void setCreateDate(long createDate) {
+        this.createDate = (int) HfsUtils.getDate(createDate / 1000L, true);
     }
 
-    public void setContentModDate(int contentModDate) {
-        this.contentModDate = contentModDate;
+    public void setContentModDate(long contentModDate) {
+        this.contentModDate = (int) HfsUtils.getDate(contentModDate / 1000L, 
true);
     }
 
     public void setAttrModDate(int attrModDate) {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Jnode-svn-commits mailing list
Jnode-svn-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits

Reply via email to