mof

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 9 Imported by: 0

README

mof

mof: make one file.

An archive algorithm.

API documentation can be found on godoc

How it Works

First use the MTF function to produce a two files and then pass it to MOF function which would now produce one file.

Description (MTF)
Packing

The first file is the index file which contains the fullname ( parent directory(s) and file name) of every file in the archive and the size of the file.

The second file is the data file which contains the contents of every file written to it in the order it was written in the index file (first file).

Unpacking

For the first entry (full file name and path) in the index file, you create the file with the name from the index file and read from the data file the size of the entry and store in the newly created file.

For other entries you sum up the sizes of all the entries before the entry you want to extract. Then you seek to this sum, create the full file name from the current entry and then read data with the size of the data file and write it to the full file name.

Description (MOF)
Packing

First create an MTF archive.

Make a new file and write the size of the index file from above and add a newline. Then write the index file and then the data file.

Unpacking

Loop until you get to the first newline and use that to get the size of the index file.

Read the index file into a temporary file (use the size gotten above) and start from the size of the size of the index file with the newline.

Then compute the size of the data file subtracting the size of the index file and the size of the size of the index file. Use this size to write the data file to a new file.

Then pass the gotten index file and data file to the UndoMTF function.

License

Released with MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MOF

func MOF(dir, archivePath string) error

MOF : Make One File This first calls MTF to get two files and then combine them into one file.

It expects a directory for its input. this would contain all the files or subdirectories with files you want to archive.

It expects a path which ends with the name of the archive.

func MTF

func MTF(dir, outDir string) (string, string, error)

MTF: Make Two Files.

This does the packing of files in to two files. It expects a directory for its input. this would contain all the files or subdirectories with files you want to archive. It also expects another directory for the output of itself.

func UndoMOF

func UndoMOF(mofFilePath, outDir string) error

UndoMOF undoes archives created with the MOF function

It first undoes the archive into two files and then passes the two files to the UndoMTF function. It expects the path of the mof file created with the MOF function and the outDir as the output directory.

func UndoMTF

func UndoMTF(indexFilePath, dataFilePath, outDir string) error

UndoMTF extracts the files to their full names ( directory and file name) in the folder supplied as the outDir

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL