Code Monkey home page Code Monkey logo

egpack's Introduction

EGPack

Build Status Issues Status License Contact
Donate-Patreon Donate-Gratipay Donate-Paypal

About

EGPack is an archive utility, similar to the TAR utility.

Documentation

Compiling and installing

EGPack should compile on every POSIX compliant operating system with an ANSI-C compiler.

To compile EGPack, simply type make from a console prompt, from the EGPack root directory.

Installation of the egpack utility is done through the make install command.

Usage

In order to archive a file or a directory, invoke the egpack binary with the -a argument, followed by the name of the file or directory to archive:

egpack -a path/to/directory/

Un-archiving is done with the -uoption:

egpack -u path/to/archive.egpk

Here are the available command line arguments that can be passed to the egpack binary:

  • -a
    Archives a file or a directory.
  • -u
    Un-archives an EGPK archive file.
  • -v
    Prints the EGPK version number.
  • -h
    Prints the EGPK help dialog
  • -d
    Turns on debugging mode

File format specification

About

EGPack uses its own specific file format, which is not compatible with other archive formats, such as the TAR format.

Format

The EGPack format consists of several specific header blocks, followed by the file(s) content.

An EPKG file must start with the main header, which is 72 bytes long.

The first four bytes represent the file format signature, which consists of the ASCII EGPK characters (0x45 0x47 0x50 0x4B).
The next four bytes are used to store the archive creation time.

Other bytes are reserved for format extension, and should be all zeros.

In C, the EGPK header is represented the following way:

struct egpack_header
{
    uint8_t  id[ 4 ];
    uint32_t ctime;
    uint8_t  pad[ 64 ];
};

Each file or directory entry is preceded by an entry header, which is 72 bytes long.

The first byte is used for the entry type. It's value can be:

  • 0: Regular file
  • 1: Directory
  • 2: Symbolic link

The second four bytes are used to store the depth of the file, from the archive's root directory.
In order to avoid limitations on the path length, all filenames are stored without the path (only the basename with extension).
So the depth value is used to indicate the file or directory depth, relative to the previous entry.

Other bytes are reserved for format extension, and should be all zeros.

In C, an entry header is represented the following way:

struct egpack_header_entry
{
    uint8_t  type;
    uint32_t depth;
    uint8_t  pad[ 64 ];
};

Depending on the entry type, the following bytes are used to represents a file, directory, or symbolic link informations.

An file entry header is 641 bytes long

The first 512 bytes are used for the filename, which is a NULL terminated string.

The next four bytes are used to store the file size, in bytes.

Following 12 bytes represents respectively the file's creation time, the last modification time, and the last access time.
Each value is 4 bytes long.

The next fours bytes are used for the file's permissions.

The next eight bytes represents respectively the owner ID and the group ID.
Each value is 4 bytes long.

Following 33 bytes are the MD5 checksum of the file.
The value is a NULL terminated string.

Other bytes are reserved for format extension, and should be all zeros.

In C, a file entry header is represented the following way:

struct egpack_header_entry_file
{
    uint8_t   name[ 512 ];
    uint64_t  size;
    uint32_t  ctime;
    uint32_t  mtime;
    uint32_t  atime;
    uint32_t  mode;
    uint32_t  uid;
    uint32_t  gid;
    uint8_t   md5[ 33 ];
    uint8_t   pad[ 64 ];
};

A directory entry header contains the same fields, except the size and md5 fields.

A directory header is 600 bytes long.

In C, a file entry header is represented the following way:

struct egpack_header_entry_dir
{
    uint8_t   name[ 512 ];
    uint32_t  ctime;
    uint32_t  mtime;
    uint32_t  atime;
    uint32_t  mode;
    uint32_t  uid;
    uint32_t  gid;
    uint8_t   pad[ 64 ];
};

A symbolic link header is the same as a file entry header, with the addition of a target field, representing the symbolic link target file, and without the md5 field.

A directory header is 1632 bytes long.

In C, a file entry header is represented the following way:

struct egpack_header_entry_symlink
{
    uint8_t   name[ 512 ];
    uint8_t   target[ 1024 ];
    uint32_t  ctime;
    uint32_t  mtime;
    uint32_t  atime;
    uint32_t  mode;
    uint32_t  uid;
    uint32_t  gid;
    uint8_t   pad[ 64 ];
};

For files, the entry is followed by the file's data.

For directories, the directory header is immediately followed by other entries headers.

License

EGPack is released under the terms of the Boost Software License - Version 1.0.

Repository Infos

Owner:			Jean-David Gadina - XS-Labs
Web:			www.xs-labs.com
Blog:			www.noxeos.com
Twitter:		@macmade
GitHub:			github.com/macmade
LinkedIn:		ch.linkedin.com/in/macmade/
StackOverflow:	stackoverflow.com/users/182676/macmade

egpack's People

Contributors

macmade avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

pradorocchi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.