rossi.fstools.fs.fatfs
Class FatDirEntry

java.lang.Object
  extended byrossi.fstools.fs.fatfs.FatDirEntry
All Implemented Interfaces:
DiskStructure, Inode, InodePtr

public class FatDirEntry
extends java.lang.Object
implements DiskStructure, Inode, InodePtr

Representation of a FAT directory entry.

  On disk the superblock looks like this:

        31        24        16       8       0
        --------------------------------------
  0000  |           Name                     |
        --------------------------------------
  0004  |           Name                     |
        --------------------------------------
  0008  |           Ext             |Attr    |
        --------------------------------------
  000C  | lcase | ctimems  | CTime           |
        --------------------------------------
  0010  |   CDate          |   ADate         |
        --------------------------------------
  0014  |   Start High     |   Time          |
        --------------------------------------
  0018  |   Date           |   Start         |
        --------------------------------------
  001C  |           Size                     |
        --------------------------------------

 


Field Summary
protected  int adate
          Access date in msdos format.
protected  byte attr
          Attributes.
static int ATTR_ARCH
          Arhive attribute.
static int ATTR_DIR
          Directory attribute.
static int ATTR_HIDDEN
          Hidden attribute.
static int ATTR_LFN
          Long filename indicator for VFAT.
static int ATTR_NONE
          No attribute bits.
static int ATTR_RO
          read-only attribute.
static int ATTR_SYS
          System attribute.
static int ATTR_VOLUME
          Volume attribute.
static int CASE_LOWER_BASE
          Base of shortname is in lowercase.
static int CASE_LOWER_EXT
          Ext of shortname is in lowercase.
protected  int cdate
          Creation date in msdos format.
protected  int ctime
          Creation time in msdos format.
protected  int ctimems
          Creation time milliseconds.
protected  int date
          Modification date.
protected  byte[] ext
          Three byte extension of the short name.
protected  byte hashValue
          Hash of the short name.
protected  byte lcase
          Lower case indicator for Windows NT.
protected  java.lang.String longName
          Long filename.
protected  byte[] name
          First 8 bytes of the short name.
protected  long size
          File size.
protected  int start
          Low 16 bits of starting cluster.
protected  int starthi
          High 16 bits of the starting cluster for FAT32.
protected  int time
          Modification time.
 
Fields inherited from interface rossi.fstools.fs.Inode
BLOCKDEV_MODE, CHARDEV_MODE, DIRECTORY_MODE, FIFO_MODE, FILE_MODE, FILETYPE_MASK, SOCKET_MODE, SYMLINK_MODE
 
Constructor Summary
FatDirEntry()
          Default constructor.
 
Method Summary
protected  int date_dos2unix(int time, int date)
          Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70).
 long getAccessTime()
          Get the time the data was last accessed.
 int getAdate()
          Get the last access date.
 byte getAttr()
          Get the attributes for this file.
 int getCdate()
          Get the creation date.
 long getChangedTime()
          Get the time this Inode metadata was last changed.
 int getCtime()
          Get the creation time of day.
 int getCtimems()
          Get the creation time milliseconds.
 int getDataSize()
          Get the size in bytes of the structure.
 int getDate()
          Get the last modified date.
 byte[] getExt()
          Get the short name extension.
 long getGroupId()
          Get the group id of the object's owner.
 byte getHashValue()
          Get the hash value of the short name.
 byte getLcase()
          Get the lowercase indicator.
 java.lang.String getLongName()
          Get the long filename.
 int getMode()
          Encode the FAT attributes into the unix mode field.
 long getModifyTime()
          Get the time the data was last modified.
 java.lang.String getName()
          Return the long name if it exists, short name otherwise.
 byte[] getNamePrefix()
          Get the short name prefix.
 long getNumLinks()
          Get the number of hard links to this file.
 java.lang.String getShortName()
          Get the short filename.
 long getSize()
          Get the size of the data associated with the object.
 int getStart()
          Get the lower 16 bits of the starting cluster.
 int getStartHi()
          Get the high 16 bits of the starting cluster for FAT32 only.
 int getTime()
          Get the last modified time of day.
 long getUserId()
          Get the user id of the object's owner.
 void loadFromBuffer(byte[] buffer, int offset)
          Loads the object from a memory buffer
 void setAccessTime(long aAccessTime)
          Not supported.
 void setAdate(int aAdate)
           
 void setAttr(byte aAttr)
           
 void setCdate(int aCdate)
           
 void setChangedTime(long aChangedTime)
          Not supported.
 void setCtime(int aCtime)
           
 void setCtimems(int aCtimems)
           
 void setDate(int aDate)
           
 void setExt(byte[] aExt)
           
 void setGroupId(long aGroupId)
          Not supported.
 void setLcase(byte aLcase)
           
 void setLongName(java.lang.String aLongName)
           
 void setMode(int aMode)
          Not supported.
 void setModifyTime(long aModifyTime)
          Not supported.
 void setNamePrefix(byte[] aName)
           
 void setNumLinks(long aNumLinks)
          Not supported.
 void setSize(long aSize)
           
 void setStart(int aStart)
           
 void setStartHi(int aStarthi)
           
 void setTime(int aTime)
           
 void setUserId(long aUserId)
          Not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected byte[] name
First 8 bytes of the short name.


ext

protected byte[] ext
Three byte extension of the short name.


attr

protected byte attr
Attributes.


lcase

protected byte lcase
Lower case indicator for Windows NT.


ctimems

protected int ctimems
Creation time milliseconds.


ctime

protected int ctime
Creation time in msdos format.


cdate

protected int cdate
Creation date in msdos format.


adate

protected int adate
Access date in msdos format.


starthi

protected int starthi
High 16 bits of the starting cluster for FAT32.


time

protected int time
Modification time.


date

protected int date
Modification date.


start

protected int start
Low 16 bits of starting cluster.


size

protected long size
File size.


hashValue

protected byte hashValue
Hash of the short name.


longName

protected java.lang.String longName
Long filename.


ATTR_NONE

public static final int ATTR_NONE
No attribute bits.

See Also:
Constant Field Values

ATTR_RO

public static final int ATTR_RO
read-only attribute.

See Also:
Constant Field Values

ATTR_HIDDEN

public static final int ATTR_HIDDEN
Hidden attribute.

See Also:
Constant Field Values

ATTR_SYS

public static final int ATTR_SYS
System attribute.

See Also:
Constant Field Values

ATTR_VOLUME

public static final int ATTR_VOLUME
Volume attribute.

See Also:
Constant Field Values

ATTR_DIR

public static final int ATTR_DIR
Directory attribute.

See Also:
Constant Field Values

ATTR_ARCH

public static final int ATTR_ARCH
Arhive attribute.

See Also:
Constant Field Values

ATTR_LFN

public static final int ATTR_LFN
Long filename indicator for VFAT. This combination of attributes indicates the the entry is part of a long filename.

See Also:
Constant Field Values

CASE_LOWER_BASE

public static final int CASE_LOWER_BASE
Base of shortname is in lowercase.

See Also:
Constant Field Values

CASE_LOWER_EXT

public static final int CASE_LOWER_EXT
Ext of shortname is in lowercase.

See Also:
Constant Field Values
Constructor Detail

FatDirEntry

public FatDirEntry()
Default constructor.

Method Detail

getDataSize

public int getDataSize()
Description copied from interface: DiskStructure
Get the size in bytes of the structure. For variable length sturctures this may represent the minimum length rather than the actual length.

Specified by:
getDataSize in interface DiskStructure
Returns:
the size of the structure.

getNamePrefix

public byte[] getNamePrefix()
Get the short name prefix.

Returns:
prefix.

setNamePrefix

public void setNamePrefix(byte[] aName)

getExt

public byte[] getExt()
Get the short name extension.

Returns:
extension

setExt

public void setExt(byte[] aExt)

getAttr

public byte getAttr()
Get the attributes for this file. This gets mapped into file mode.

Returns:
attributes

setAttr

public void setAttr(byte aAttr)

getLcase

public byte getLcase()
Get the lowercase indicator.

Returns:
lcase

setLcase

public void setLcase(byte aLcase)

getCtimems

public int getCtimems()
Get the creation time milliseconds.

Returns:
int

setCtimems

public void setCtimems(int aCtimems)

getCtime

public int getCtime()
Get the creation time of day.

Returns:
int

setCtime

public void setCtime(int aCtime)

getCdate

public int getCdate()
Get the creation date.

Returns:
int

setCdate

public void setCdate(int aCdate)

getAdate

public int getAdate()
Get the last access date.

Returns:
int

setAdate

public void setAdate(int aAdate)

getStartHi

public int getStartHi()
Get the high 16 bits of the starting cluster for FAT32 only.

Returns:
int

setStartHi

public void setStartHi(int aStarthi)

getTime

public int getTime()
Get the last modified time of day.

Returns:
int

setTime

public void setTime(int aTime)

getDate

public int getDate()
Get the last modified date.

Returns:
int

setDate

public void setDate(int aDate)

getStart

public int getStart()
Get the lower 16 bits of the starting cluster.

Returns:
int

setStart

public void setStart(int aStart)

getSize

public long getSize()
Description copied from interface: Inode
Get the size of the data associated with the object. This is mostly meaningful with normal files.

Specified by:
getSize in interface Inode
Returns:
the size

setSize

public void setSize(long aSize)
Specified by:
setSize in interface Inode

getMode

public int getMode()
Encode the FAT attributes into the unix mode field.

The encoding goes as follows. This is somewhat arbitrary.

If attribute State Add mode bits
ATTR_DIR set Inode.DIRECORY_MODE
ATTR_DIR clear Inode.FILE_MODE
ATTR_RO clear ugo+w
ATTR_HIDDEN clear u+r
ATTR_SYS clear g+r
ATTR_ARCHIVE clear o+r
ATTR_VOLUME set o+x

Specified by:
getMode in interface Inode
Returns:
encoded attributes

setMode

public void setMode(int aMode)
Not supported. Will throw UnsupportedOperationException if called.

Specified by:
setMode in interface Inode
Parameters:
aMode - the mode.
See Also:
Inode.getMode()

getNumLinks

public long getNumLinks()
Description copied from interface: Inode
Get the number of hard links to this file. A value of zero indicates that the object is deleted. A hard link is a directory entry pointing directly at this object (not via symlinks).

Specified by:
getNumLinks in interface Inode
Returns:
the number of links

setNumLinks

public void setNumLinks(long aNumLinks)
Not supported. Will throw UnsupportedOperationException if called.

Specified by:
setNumLinks in interface Inode
Parameters:
aNumLinks - number of links.

getUserId

public long getUserId()
Description copied from interface: Inode
Get the user id of the object's owner.

Specified by:
getUserId in interface Inode
Returns:
the user id

setUserId

public void setUserId(long aUserId)
Not supported. Will throw UnsupportedOperationException if called.

Specified by:
setUserId in interface Inode
Parameters:
aUserId - user id

getGroupId

public long getGroupId()
Description copied from interface: Inode
Get the group id of the object's owner.

Specified by:
getGroupId in interface Inode
Returns:
the group id

setGroupId

public void setGroupId(long aGroupId)
Not supported. Will throw UnsupportedOperationException if called.

Specified by:
setGroupId in interface Inode
Parameters:
aGroupId - group id

getAccessTime

public long getAccessTime()
Description copied from interface: Inode
Get the time the data was last accessed.

Specified by:
getAccessTime in interface Inode
Returns:
the access time.

setAccessTime

public void setAccessTime(long aAccessTime)
Not supported. Will throw UnsupportedOperationException if called.

Specified by:
setAccessTime in interface Inode
Parameters:
aAccessTime - accessTime

getModifyTime

public long getModifyTime()
Description copied from interface: Inode
Get the time the data was last modified.

Specified by:
getModifyTime in interface Inode
Returns:
the access time.

setModifyTime

public void setModifyTime(long aModifyTime)
Not supported. Will throw UnsupportedOperationException if called.

Specified by:
setModifyTime in interface Inode
Parameters:
aModifyTime - modifyTime

getChangedTime

public long getChangedTime()
Description copied from interface: Inode
Get the time this Inode metadata was last changed.

Specified by:
getChangedTime in interface Inode
Returns:
long

setChangedTime

public void setChangedTime(long aChangedTime)
Not supported. Will throw UnsupportedOperationException if called.

Specified by:
setChangedTime in interface Inode
Parameters:
aChangedTime - changedTime

date_dos2unix

protected int date_dos2unix(int time,
                            int date)
Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70). Borrowed from the Linux kernel sources. fs/fat/misc.c

Parameters:
time - msdos time
date - msdos date
Returns:
unix time

getHashValue

public byte getHashValue()
Get the hash value of the short name. return hash value


getLongName

public java.lang.String getLongName()
Get the long filename. Returns null if no long filename.

Returns:
long file name.

setLongName

public void setLongName(java.lang.String aLongName)

getName

public java.lang.String getName()
Return the long name if it exists, short name otherwise.

Returns:
filename

getShortName

public java.lang.String getShortName()
Get the short filename.

Returns:
short filename.

loadFromBuffer

public void loadFromBuffer(byte[] buffer,
                           int offset)
                    throws FsException
Description copied from interface: DiskStructure
Loads the object from a memory buffer

Specified by:
loadFromBuffer in interface DiskStructure
Parameters:
buffer - a byte[] containing data to be read in populating the object
offset - a int indicating the offset within the buffer to start parsing.
Throws:
FsException - if a parse error occurs.