From: <ls...@us...> - 2009-01-05 15:09:07
|
Revision: 4830 http://jnode.svn.sourceforge.net/jnode/?rev=4830&view=rev Author: lsantha Date: 2009-01-05 15:09:00 +0000 (Mon, 05 Jan 2009) Log Message: ----------- Added read support for STANDARD_INFORMATION attribute, by Daniel Noll. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/ntfs/FileNameAttribute.java trunk/fs/src/fs/org/jnode/fs/ntfs/FileRecord.java trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSAttribute.java trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java Added Paths: ----------- trunk/fs/src/fs/org/jnode/fs/ntfs/StandardInformationAttribute.java Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/FileNameAttribute.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ntfs/FileNameAttribute.java 2009-01-04 16:37:04 UTC (rev 4829) +++ trunk/fs/src/fs/org/jnode/fs/ntfs/FileNameAttribute.java 2009-01-05 15:09:00 UTC (rev 4830) @@ -128,6 +128,15 @@ } /** + * Gets the time when the MFT record last changed. + * + * @return the MFT change 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. Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/FileRecord.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ntfs/FileRecord.java 2009-01-04 16:37:04 UTC (rev 4829) +++ trunk/fs/src/fs/org/jnode/fs/ntfs/FileRecord.java 2009-01-05 15:09:00 UTC (rev 4830) @@ -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) { Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSAttribute.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSAttribute.java 2009-01-04 16:37:04 UTC (rev 4829) +++ trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSAttribute.java 2009-01-05 15:09:00 UTC (rev 4830) @@ -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); Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java 2009-01-04 16:37:04 UTC (rev 4829) +++ trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java 2009-01-05 15:09:00 UTC (rev 4830) @@ -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())); } /** Added: trunk/fs/src/fs/org/jnode/fs/ntfs/StandardInformationAttribute.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ntfs/StandardInformationAttribute.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/ntfs/StandardInformationAttribute.java 2009-01-05 15:09:00 UTC (rev 4830) @@ -0,0 +1,64 @@ +package org.jnode.fs.ntfs; + +/** + * @author Daniel Noll (da...@no...) + */ +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 MFT change 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+) +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |