Index: fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java =================================================================== --- fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java (revision 4829) +++ fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java (working copy) @@ -70,18 +70,31 @@ } public long getCreated() throws IOException { - return NTFSUTIL.filetimeToMillis(getFileRecord().getFileNameAttribute() - .getCreationTime()); + final FileRecord record = getFileRecord(); + return NTFSUTIL.filetimeToMillis( + Math.max(record.getStandardInformationAttribute().getCreationTime(), + record.getFileNameAttribute().getCreationTime())); } public long getLastModified() throws IOException { - return NTFSUTIL.filetimeToMillis(getFileRecord().getFileNameAttribute() - .getModificationTime()); + final FileRecord record = getFileRecord(); + return NTFSUTIL.filetimeToMillis( + Math.max(record.getStandardInformationAttribute().getModificationTime(), + record.getFileNameAttribute().getModificationTime())); } + public long getLastChanged() throws IOException { + final FileRecord record = getFileRecord(); + return NTFSUTIL.filetimeToMillis( + Math.max(record.getStandardInformationAttribute().getMftChangeTime(), + record.getFileNameAttribute().getMftChangeTime())); + } + public long getLastAccessed() throws IOException { - return NTFSUTIL.filetimeToMillis(getFileRecord().getFileNameAttribute() - .getAccessTime()); + final FileRecord record = getFileRecord(); + return NTFSUTIL.filetimeToMillis( + Math.max(record.getStandardInformationAttribute().getAccessTime(), + record.getFileNameAttribute().getAccessTime())); } /** Index: fs/src/fs/org/jnode/fs/ntfs/FileNameAttribute.java =================================================================== --- fs/src/fs/org/jnode/fs/ntfs/FileNameAttribute.java (revision 4829) +++ fs/src/fs/org/jnode/fs/ntfs/FileNameAttribute.java (working copy) @@ -128,6 +128,15 @@ } /** + * Gets the time when the MFT record last changed. + * + * @return the modification time, as a 64-bit NTFS filetime value. + */ + public long getMftChangeTime() { + return getInt64(getAttributeOffset() + 0x18); + } + + /** * Gets the access time. * * @return the access time, as a 64-bit NTFS filetime value. Index: fs/src/fs/org/jnode/fs/ntfs/FileRecord.java =================================================================== --- fs/src/fs/org/jnode/fs/ntfs/FileRecord.java (revision 4829) +++ fs/src/fs/org/jnode/fs/ntfs/FileRecord.java (working copy) @@ -48,6 +48,11 @@ private AttributeListAttribute attributeListAttribute; /** + * Cached standard information attribute. + */ + private StandardInformationAttribute standardInformationAttribute; + + /** * Cached file name attribute. */ private FileNameAttribute fileNameAttribute; @@ -226,9 +231,22 @@ } /** - * Gets the filename attribute of this filerecord. + * Gets the standard information attribute for this file record. + * + * @return the standard information attribute. + */ + public StandardInformationAttribute getStandardInformationAttribute() { + if (standardInformationAttribute == null) { + standardInformationAttribute = + (StandardInformationAttribute) findAttributeByType(NTFSAttribute.Types.STANDARD_INFORMATION); + } + return standardInformationAttribute; + } + + /** + * Gets the file name attribute for this file record. * - * @return the filename attribute. + * @return the file name attribute. */ public FileNameAttribute getFileNameAttribute() { if (fileNameAttribute == null) { Index: fs/src/fs/org/jnode/fs/ntfs/StandardInformationAttribute.java =================================================================== --- fs/src/fs/org/jnode/fs/ntfs/StandardInformationAttribute.java (revision 0) +++ fs/src/fs/org/jnode/fs/ntfs/StandardInformationAttribute.java (revision 0) @@ -0,0 +1,64 @@ +package org.jnode.fs.ntfs; + +/** + * @author Daniel Noll (daniel@noll.id.au) + */ +public class StandardInformationAttribute extends NTFSResidentAttribute { + + /** + * Constructs the attribute. + * + * @param fileRecord the containing file record. + * @param offset offset of the attribute within the file record. + */ + public StandardInformationAttribute(FileRecord fileRecord, int offset) { + super(fileRecord, offset); + } + + /** + * Gets the creation time. + * + * @return the creation time, as a 64-bit NTFS filetime value. + */ + public long getCreationTime() { + return getInt64(getAttributeOffset()); + } + + /** + * Gets the modification time. + * + * @return the modification time, as a 64-bit NTFS filetime value. + */ + public long getModificationTime() { + return getInt64(getAttributeOffset() + 0x08); + } + + /** + * Gets the time when the MFT record last changed. + * + * @return the modification time, as a 64-bit NTFS filetime value. + */ + public long getMftChangeTime() { + return getInt64(getAttributeOffset() + 0x10); + } + + /** + * Gets the access time. + * + * @return the access time, as a 64-bit NTFS filetime value. + */ + public long getAccessTime() { + return getInt64(getAttributeOffset() + 0x18); + } + + // TODO: The following fields have not yet been implemented due to no immediate need: + // offset bytes description + // 0x20 4 Flags + // 0x24 4 Maximum number of versions + // 0x28 4 Version number + // 0x2C 4 Class ID + // 0x30 4 Owner ID (version 3.0+) + // 0x34 4 Security ID (version 3.0+) + // 0x38 8 Quota charged (version 3.0+) + // 0x40 8 Update Sequence Number (USN) (version 3.0+) +} Index: fs/src/fs/org/jnode/fs/ntfs/NTFSAttribute.java =================================================================== --- fs/src/fs/org/jnode/fs/ntfs/NTFSAttribute.java (revision 4829) +++ fs/src/fs/org/jnode/fs/ntfs/NTFSAttribute.java (working copy) @@ -174,6 +174,8 @@ final int type = fileRecord.getUInt32AsInt(offset + 0x00); switch (type) { + case Types.STANDARD_INFORMATION: + return new StandardInformationAttribute(fileRecord, offset); case Types.ATTRIBUTE_LIST: if (resident) { return new AttributeListAttributeRes(fileRecord, offset);