The PyFFF API Reference

class fff.AbstractFile

This is the generic File interface.

allocated_size

The allocated size of this file on disk. Abstract property.

Type:int
data

The data of this file in bytes. Abstract property.

Type:bytes
fullpath

The full path of this file. E.g. “/usr/local/bin/python”. Abstract property.

Note

For root directory, it returns “/”.

Type:str
mime

The mime type of this file. E.g. “application/x-gzip”. Abstract property.

Type:str
name

The name of this file. Abstract property.

Type:str
parent

The parent directory of this file. Abstract property.

Type:AbstractFile
read(count: int, skip: int, bsize: int) → Iterable[bytes]

Read file data at given location. Abstract method.

Parameters:
  • count (int) – The number of data unit to read.
  • skip (int) – The number of data unit to skip before read.
  • bsize (int) – The size of data unit. (Block size)
Returns:

The result is a generate of bytes.

Return type:

Iterable[bytes]

Examples

Read the 2nd cluster of the file.

>>> f.read(count=1, skip=1, bsize=fs.cluster_size)
b'This is the data contained in the second cluster of this file... [truncated]'
size

The actual size of this file on disk. Abstract property.

Type:int
fff.util.hd(*args, **kwargs)

This is an alias to the hexdump function.

fff.util.md5sum(data: Union[bytes, Iterable[bytes], fff.abstract_file.AbstractFile]) → str

Returns the MD5 checksum of bytes, an iterable of bytes, or a file.

Parameters:data (bytes, Iterable[bytes], or AbstractFile) – The data/file to calculate MD5 checksum on.
Returns:The MD5 checksum string.
Return type:str
fff.util.hexdump(data, result='print')

Transform binary data to the hex dump text format:

00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 …………….

[x] data argument as a binary string [x] data argument as a file like object
Returns result depending on the result argument:
‘print’ - prints line by line ‘return’ - returns single string ‘generator’ - returns generator that produces lines