These are the objects of the TPFS system: namely, files and tags. This module provides the low-level functions for managing file/tag info and their respective tables, as well as somewhat higher-level functions for more sane access.
- data FileID
- isFileIDInUse :: Device m h => Filesystem m h -> FileID -> m Bool
- lookupByFileID :: Device m h => Filesystem m h -> FileID -> m (Maybe Address)
- addToFileTable :: Device m h => Filesystem m h -> (FileID, Address) -> m ()
- removeFromFileTable :: Device m h => Filesystem m h -> FileID -> m ()
- data FileInfo = FileInfo {
- fileID :: FileID
- firstBlock :: Address
- lastBlock :: Address
- fileOffset :: Word64
- fileLength :: Word64
- isLocked :: Bool
- tagHashes :: [TagHash]
- getFileInfo :: Device m h => Filesystem m h -> Address -> m FileInfo
- putFileInfo :: Device m h => Filesystem m h -> Address -> FileInfo -> m ()
- createFileInfo :: Device m h => Filesystem m h -> FileInfo -> m Address
- removeFileInfo :: Device m h => Filesystem m h -> Address -> m ()
- data TagHash
- lookupByTagHash :: Device m h => Filesystem m h -> TagHash -> m (Maybe Address)
- addToTagTable :: Device m h => Filesystem m h -> (TagHash, Address) -> m ()
- removeFromTagTable :: Device m h => Filesystem m h -> TagHash -> m ()
- data TagInfo = TagInfo {}
- getTagInfo :: Device m h => Filesystem m h -> Address -> m TagInfo
- putTagInfo :: Device m h => Filesystem m h -> Address -> TagInfo -> m ()
- createTagInfo :: Device m h => Filesystem m h -> TagInfo -> m Address
- removeTagInfo :: Device m h => Filesystem m h -> Address -> m ()
File objects
The file table
File identification numbers are 128 bits long and are usually
randomly generated. As such, there is a Random
instance for
FileID
s. Be careful when using this, however. It is possible
(though unlikely) for a collision to occur, so it is strongly
recommended to use isFileIDInUse
to ensure the FileID
is not
already in use when generating a FileID
in this manner.
:: Device m h | |
=> Filesystem m h | |
-> FileID | The |
-> m Bool |
:: Device m h | |
=> Filesystem m h | |
-> (FileID, Address) | The ID of the file in question, and the address of the first block of its record. |
-> m () |
Links a file information record to the file table so that it may be discovered.
Note that a file information record (represented by FileInfo
)
must be linked to the file table in order for it to be found.
:: Device m h | |
=> Filesystem m h | |
-> FileID | The file to be unlinked. |
-> m () |
Unlinks a file information table from the file table. This prevents the file from being discovered.
It is possible for a file to be 'lost' if it is not linked, so take care when using this function manually.
File information blocks
The FileInfo
structure attaches the blocks of a file to its
identification (FileID
and tags) and other information vital for
reading the file (offset, length, lock).
FileInfo | |
|
:: Device m h | |
=> Filesystem m h | |
-> Address | The first block of the file information record. |
-> m FileInfo |
Reads the file information from a file information record.
:: Device m h | |
=> Filesystem m h | |
-> Address | The first block of the file information record to be modified. |
-> FileInfo | The file information to place in the record. |
-> m () |
Modifies the file information in a file information record. Does
not affect tag structures linked via tagHashes
.
:: Device m h | |
=> Filesystem m h | |
-> FileInfo | The initial contents of the file information record. |
-> m Address | A pointer to the first block of the newly created record. |
Creates a new file information record. Won't link the file to the
file table, nor affect tag structures linked via tagHashes
.
:: Device m h | |
=> Filesystem m h | |
-> Address | The address of the first block in the file information record to be removed. |
-> m () |
Frees the blocks used by a file information record. Does not free blocks used by the file itself.
Note: removeFileInfo
won't automatically unlink the file from the
file table nor any tags linked to it. These operations should both
be done before calling removeFileInfo
.
High-level access
Tag objects
The tag table
:: Device m h | |
=> Filesystem m h | |
-> TagHash | The hash of the tag to look up. |
-> m (Maybe Address) |
|
Looks for a tag information record by its hash.
:: Device m h | |
=> Filesystem m h | |
-> (TagHash, Address) | The hash of the tag in question, and the address of its information record. |
-> m () |
Links a tag information record to the tag table.
removeFromTagTable :: Device m h => Filesystem m h -> TagHash -> m ()Source
Removes a tag information record from the tag table.
Note: There is really no good reason to do this, as tags are usually managed automatically.
Tag information blocks
Describes a tag information record.
TagInfo | |
|
:: Device m h | |
=> Filesystem m h | |
-> Address | The first block of the tag information record. |
-> m TagInfo |
Reads a TagInfo
structure from a tag information record on
disk.
:: Device m h | |
=> Filesystem m h | |
-> Address | The first block of the tag information record to be modified. |
-> TagInfo | The tag information to place in the record. |
-> m () |
Writes a TagInfo
structure to a tag information record on disk.
:: Device m h | |
=> Filesystem m h | |
-> TagInfo | The initial contents of the tag information record. |
-> m Address | A pointer to the first block of the newly created record. |
Creates a new tag information record. Won't link the tag to the
tag table, nor affect files linked via fileIDs
.
Note: A tag information record is fairly useless if not linked.
:: Device m h | |
=> Filesystem m h | |
-> Address | The address of the first block in the tag information record to be removed. |
-> m () |
Frees the blocks used by a tag information record. This function is mostly for internal use, as tag information records are usually managed automatically.
Note: removeTagInfo
won't automatically unlink the tag from the
tag table nor any files linked to it. These operations should both
be done before calling removeTagInfo
.