ntfsbootrecord.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 159 行
JAVA
159 行
/*
* $Id: NTFSBootRecord.java,v 1.7 2004/01/19 17:45:45 vchira_2000 Exp $
*/
package org.jnode.fs.ntfs;
/**
* @author Chira
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class NTFSBootRecord
{
private String SystemID = null;
private int BytesPerSector;
private byte SectorPerCluster;
private int MFTPointer;
private byte MediaDescriptor;
private int SectorsPerTrack;
private int clustersPerMFTRecord = 0;
private int totalSectors;
// try to cache this value
private int bytesPerFileRecord = -1;
/**
* @param buffer
*/
public void initBootRecordData(byte[] buffer)
{
this.SystemID = new String(buffer,0x03,8);
this.BytesPerSector = NTFSUTIL.LE_READ_U16_INT(buffer[0x0B],buffer[0x0C]);
this.SectorPerCluster = buffer[0x0D];
// LONG LONG fix it!!
this.MFTPointer = NTFSUTIL.LE_READ_U32_INT(buffer,0x30);//makeWORDfrom2Bytes(byteMFTPointer[0],byteMFTPointer[1]);
this.MediaDescriptor = buffer[0x15];
this.SectorsPerTrack = NTFSUTIL.LE_READ_U16_INT(buffer[0x18],buffer[0x19]);
this.clustersPerMFTRecord = NTFSUTIL.LE_READ_32_INT(buffer,0x40);
this.totalSectors = NTFSUTIL.LE_READ_U32_INT(buffer,0x28);
}
public int getMFTByteStart()
{
return (this.MFTPointer * this.SectorPerCluster)* this.BytesPerSector;
}
/**
* @return Returns the bytesPerSector.
*/
public int getBytesPerSector() {
return this.BytesPerSector;
}
/**
* @param bytesPerSector The bytesPerSector to set.
*/
public void setBytesPerSector(int bytesPerSector) {
this.BytesPerSector = bytesPerSector;
}
/**
* @return Returns the mediaDescriptor.
*/
public byte getMediaDescriptor() {
return this.MediaDescriptor;
}
/**
* @param mediaDescriptor The mediaDescriptor to set.
*/
public void setMediaDescriptor(byte mediaDescriptor) {
this.MediaDescriptor = mediaDescriptor;
}
/**
* @return Returns the mFTPointer.
*/
public int getMFTPointer() {
return this.MFTPointer;
}
/**
* @param pointer The mFTPointer to set.
*/
public void setMFTPointer(int pointer) {
this.MFTPointer = pointer;
}
/**
* @return Returns the sectorPerCluster.
*/
public byte getSectorPerCluster() {
return this.SectorPerCluster;
}
/**
* @param sectorPerCluster The sectorPerCluster to set.
*/
public void setSectorPerCluster(byte sectorPerCluster) {
this.SectorPerCluster = sectorPerCluster;
}
/**
* @return Returns the sectorsPerTrack.
*/
public int getSectorsPerTrack() {
return this.SectorsPerTrack;
}
/**
* @param sectorsPerTrack The sectorsPerTrack to set.
*/
public void setSectorsPerTrack(int sectorsPerTrack) {
this.SectorsPerTrack = sectorsPerTrack;
}
/**
* @return Returns the systemID.
*/
public String getSystemID() {
return this.SystemID;
}
/**
* @param systemID The systemID to set.
*/
public void setSystemID(String systemID) {
this.SystemID = systemID;
}
/**
* @return Returns the totalSectors.
*/
public int getTotalSectors() {
return this.totalSectors;
}
/**
* @param totalSectors The totalSectors to set.
*/
public void setTotalSectors(int totalSectors) {
this.totalSectors = totalSectors;
}
public int getBytesPerFileRecord()
{
if(bytesPerFileRecord < 0 )
if( this.clustersPerMFTRecord > 0 )
bytesPerFileRecord = this.clustersPerMFTRecord * (this.SectorPerCluster * this.BytesPerSector);
else
bytesPerFileRecord = (1 << -this.clustersPerMFTRecord);
return bytesPerFileRecord;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?