Documentation ¶
Overview ¶
Package direntry describes FAT directory entries.
Index ¶
Constants ¶
const (
// DirentrySize is the size of a direntry struct (both long and short versions).
DirentrySize = 32
)
Variables ¶
This section is empty.
Functions ¶
func FreeDirent ¶
func FreeDirent() []byte
FreeDirent creates a byte slice representing "Free directory entry".
func LastFreeDirent ¶
func LastFreeDirent() []byte
LastFreeDirent creates a byte slice representing "Last free directory entry".
Types ¶
type Dirent ¶
type Dirent struct { Cluster uint32 // Cluster equals zero if we're opening the root directory Size uint32 // The size field includes all dirents up to and including the "last free" dirent WriteTime time.Time // The last time the file was modified // contains filtered or unexported fields }
Dirent describes an in-memory representation of a direntry. This must be an in-memory representation, rather than one which accesses persistant storage, as it gets passed back to the user when "fs.Directory.Read()" is called.
func LoadDirent ¶
func LoadDirent(callback GetDirentryCallback, direntryIndex int) (*Dirent, int, error)
LoadDirent converts a buffer of bytes (from disk) to an in-memory dirent. Returns the number of direntry slots required to represent the logical Dirent.
If the direntry is a "short" filename (or free entry), the index points to it directly.
If the direntry is a "long" filename, the index points to the first long entry, which precedes (optional) other long entries and (required) a short entry.
Otherwise, the requested direntry is invalid.
func LookupDirent ¶
func LookupDirent(callback GetDirentryCallback, name string) (*Dirent, int, error)
LookupDirent looks for (and loads) a dirent with a given name, along with the direntryIndex at which it was found.
If a Dirent with a matching name is not found, return "nil".
func New ¶
New creates a new in-memory Dirent.
Does not allocate any on-disk space; simply creates an in-memory structure.
func (*Dirent) IsLastFree ¶
IsLastFree returns true if the Dirent represents the last free spot.
func (*Dirent) Serialize ¶
func (d *Dirent) Serialize(callback GetDirentryCallback) ([]byte, error)
Serialize converts the in-memory "Dirent" to a "disk-ready" byte slice. The result should be a multiple of "DirentrySize" bytes long.
The "callback" is used to read the containing directory, and confirm that no other files exist with the same "generation number". After the dirent has been serialized once, the generation number is stored, and the callback will no longer be used (it can be nil).
type GetDirentryCallback ¶
GetDirentryCallback returns the directory entry at an index. The index is relative to the start of the directory.
This function should only need to be called once for short direntries.
For long direntries, it may need to be called multiple times to read the long direntry components.