Polish (Poland)English (United Kingdom)

What is cookfs?

Cookfs is a Tcl virtual filesystem using a compressed archive format to allow embedding multiple files in an archive that Tcl scripts can access directly.

It is optimized for storing Tcl packages (allowing around 10%-20% smaller sizes ratio than mk4vfs while still using zlib compression), small, fast and integrated with Tcl.

It is designed only for use as Tcl VFS and provides multiple optimizations especially for delivering Tcl based standalone applications.

Latest cookfs version: 1.3.1 (released 2011-10-01) | download files


Tcl/Tk - Cookfs

cookfs::fsindex(n) 1.3.2 cookfs_fsindex "vfs::cookfs::fsindex"

Name

cookfs::fsindex - vfs::cookfs::fsindex

Description

Cookfs fsindex provide a low level mechanism for storing mapping between files in cookfs archive and pages they correspond to.

This mechanism should only be used by advanced users and is only documented for reference.

COMMANDS

::cookfs::fsindex ?exportedData?

Creates a new fsindex object. If exportedData is specified, index is imported from this data and error is thrown if data is not correct.

If exportedData is not provided, new fsindex is created.

The command returns a fsindex command that can be used to perform actions on index.

fsindexHandle export

Export current index as binary data. This data can be stored in cookfs_pages object and later on imported using cookfs::fsindex command.

fsindexHandle list path

List all entries in specified path. Path should be separated by slashes. Specify empty path to list contents of main directory for archive.

fsindexHandle get path

Get information about specified entry. Path should be separated by slashes.

Method get returns file information as a list. For directories, this is a single-element list containing file modification time. For files, first element is modification time, second element is file size and third element is a list of block-offset-size triplets.

See BLOCK-OFFSET-SIZE INFORMATION for more details on block-offset-size triplets.

fsindexHandle getmtime path

Get file modification about specified entry. Path should be separated by slashes.

fsindexHandle set path mtime ?data?

Set information about specified entry. Path should be separated by slashes. If data is omitted, new entry is created as directory.

If data specified, entry is created as file and data is created as block-offset-size triplets.

See BLOCK-OFFSET-SIZE INFORMATION for more details on block-offset-size triplets.

fsindexHandle setmtime path mtime

Set file modification about specified entry. Path should be separated by slashes.

fsindexHandle unset path

Deletes specified entry. Path should be separated by slashes.

fsindexHandle delete

Delete fsindex object. Frees up all memory associated with an index.

fsindexHandle getmetadata name ?defaultValue?

Get metadata with specified name from an index, if it exists. If metadata does not exist, defaultValue is returned if specified. If metadata does not exist and defaultValue is not specified, an error is thrown.

fsindexHandle setmetadata name value

Set metadata with specified name to value. Overwrites previous value if it existed.

fsindexHandle unsetmetadata name

Removes metadata with specified name from index.

BLOCK-OFFSET-SIZE INFORMATION

Files in cookfs are described storing block-offset-size triplets. These specify block (index of cookfs page), offset in the page and size of the data in a page. Each 3 elements of a list describe one part of a file.

For example {1 0 2048} specifies that page with index 1 should be used, data starts at offset 0 and that data is 2048 bytes. Index data of {0 0 65536 1 10240 40960} specifies that data is first stored in page 0 and uses 65536 bytes from this page. Next, data is stored in page 1 from 10240-th byte and uses up another 40960 bytes. This means that file's total size is 106496 bytes.

Cookfs index only stores block-offset-size triplets and calculates size based on all sizes of its elements. Therefore setting cookfs data only requires specifying list itself, not summed up size of the file.

See Also

cookfs_fsindex

Keywords

cookfs, vfs

 
Tcl 8.5 Network Programming book
Learning Nagios 3.0 book