ntfsattribute.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 163 行
JAVA
163 行
/*
* $Id: NTFSAttribute.java,v 1.5 2004/01/19 21:20:55 vchira_2000 Exp $
*/
package org.jnode.fs.ntfs.attributes;
import 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 abstract class NTFSAttribute
{
protected byte[] buffer = null;
// only for named attributes(when name lengthe > 0)
String name = null;
private NTFSFileRecord fileRecord = null;
/**
*
*/
public NTFSAttribute(NTFSFileRecord fileRecord,byte[] buffer)
{
super();
this.buffer = buffer;
this.fileRecord = fileRecord;
}
/**
* @return Returns the attributeType.
*/
public int getAttributeType()
{
return NTFSUTIL.LE_READ_U32_INT( buffer, 0x00);
}
/*
* Flag |Description
* -------------------
* 0x0001 |Compressed
* 0x4000 |Encrypted
* 0x8000 |Sparse
*/
public int getFlags()
{
return NTFSUTIL.LE_READ_U16_INT(buffer[0x0C],buffer[0x0D]);
}
/**
* @return Returns the nameLength.
*/
public byte getNameLength()
{
return buffer[0x09];
}
/**
* @return Returns the nameOffset.
*/
public int getNameOffset()
{
return NTFSUTIL.LE_READ_U16_INT(buffer[0x0A],buffer[0x0B]);
}
/**
* @return Returns the attributeID.
*/
public int getAttributeID() {
return NTFSUTIL.LE_READ_U16_INT(buffer[0x0E],buffer[0x0F]);
}
/**
* @return Returns the attributeName.
*/
public String getAttributeName() {
// if it is named fill the attribute name
if(getNameLength() > 0)
{
char[] namebuf = new char[getNameLength()];
for(int i = 0;i < getNameLength();i++)
{
namebuf[i] = NTFSUTIL.READ16_CHAR(
buffer[getNameOffset() + (i*2)],
buffer[getNameOffset() + (i*2) + 1]);
}
return new String(namebuf);
}
return null;
}
/**
* @return Returns the volume.
*/
/**
* @return Returns the fileRecord.
*/
public NTFSFileRecord getFileRecord() {
return this.fileRecord;
}
/**
* @param fileRecord The fileRecord to set.
*/
public void setFileRecord(NTFSFileRecord fileRecord) {
this.fileRecord = fileRecord;
}
/**
* @return Returns the resident.
*/
public boolean isResident() {
return buffer[ + 0x08]==0;
}
/**
* @return Returns the name.
*/
public String getName() {
return this.name;
}
/**
* @param name The name to set.
*/
public void setName(String name) {
this.name = name;
}
public int getLength()
{
return NTFSUTIL.LE_READ_U32_INT( buffer,4);
}
public static NTFSAttribute getAttribute(NTFSFileRecord fileRecord, byte[] buffer)
{
// check the resident flag
if(buffer[0x08] ==0 )
// resident
return new NTFSResidentAttribute(fileRecord,buffer);
else
// non resident
return new NTFSNonResidentAttribute(fileRecord,buffer);
}
/**
* @return Returns the buffer.
*/
public byte[] getBuffer()
{
return buffer;
}
/**
* @param buffer The buffer to set.
*/
public void setBuffer(byte[] buffer)
{
this.buffer = buffer;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?