PDA

View Full Version : Compress File System



BlueCop
12-14-2002, 07:32 AM
this is a header file called compressfs.h it describes the compressed file system used by UltimateTV. it is used to store the WindowsCE os and interface on 3 compressed partitions. System, Browser, Storage.

#ifndef __COMPRESSFS_H
#define __COMPRESSFS_H


/*****************************************************************************
**
** This file describes the format of data on a CompressFS disk.
**
** At the begining of a CompressFS disk, there is an instance of
** a Disk structure. The Disk structure describes the disk as a whole,
** including a checksum for the entire disk, a creation date, and a count
** of the number of logical volumes that the disk contains.
**
** The d_EntryTablePos field of the Disk structure indicates where on the disk
** to find an array of Dir structrues representing the root directories of
** all the volumes for the disk. The names of these root directories are
** actually the names of the volumes.
**
** A Dir structure indicates the number of subdirectories it contains as well
** as the number of files it contains. The d_EntryTablePos field of the Dir
** structure indicates where on the disk to find an array of Dir structures
** followed by an array of File structures. The number of entries in each
** array is indicated respectively by the d_NumDirEntries and d_NumFileEntries
** fields of the Dir structure.
**
** A File structure indicates the location on the disk of the file's data.
** All data is stored contiguously. The file's data starts with an
** array of Segment structures that specify the size of each compressed
** chunk within the file. Following this array comes the actual client-level
** file data.
**
** The names of files or directories are stored within the table mentioned
** above, following each member of the array. Thus, after each File or Dir
** structure comes a NUL-terminated string which is the name of that entry.
** The name is either in Unicode or ASCII depending on the entry's header
** (see below). The maximum length of an entry name on a CompressFS volume
** is CompressFS_MaxNameSize (64).
**
** File and Dir structures are prefixed with a common Entry structure. The
** e_Flags field of an Entry structure specifies whether the entry's name is
** stored in Unicode or ASCII. The e_Compression field indicates which type
** of compression was used to compress the entry's data.
**
** The size of the File, Dir and Segment structures may be called to
** grow in the future. As a result, indexing into tables of these structures
** must be done using the structure size values specified in the Disk
** structure (see the d_FileEntrySize, d_DirEntrySize, and d_SegmentEntrySize
** fields of the Disk structure).
**
******************************************************************************/


#include <windows.h>

BlueCop
12-14-2002, 07:32 AM
/*****************************************************************************/


/* an entry within a directory */
typedef struct
{
BYTE e_Flags; /* control flags for entry, see below */
BYTE e_Compression; /* compression type of entry, see below */
} Entry;

/* flags for the Entry.e_Flags field */
#define ENTRY_FLG_UnicodeName (1 << 0) /* entry's name is in Unicode */
#define ENTRY_FLG_ShortSegments (1 << 1) /* entry uses ShortSegment */

/* types of compression for the Entry.e_Compression field */
#define ENTRY_COMPRESSION_None 0
#define ENTRY_COMPRESSION_LZJ64 1

/* a file compression segment */
typedef struct
{
DWORD s_CompressedSize; /* compressed size of segment data in bytes */
DWORD s_UncompressedSize; /* uncompressed size of segment data in bytes */
} Segment;

/* a short version of a file compression segment */
typedef struct
{
WORD ss_CompressedSize; /* compressed size of segment data in bytes */
WORD ss_UncompressedSize; /* uncompressed size of segment data in bytes */
} ShortSegment;

/* a file entry */
typedef struct
{
Entry f_Entry; /* common data */
WORD f_NumSegments; /* # of compression segments */
DWORD f_DataPos; /* absolute disk position of entry's data */
} File;

/* a directory entry */
typedef struct
{
Entry d_Entry; /* common data */
WORD d_NumDirEntries; /* # of subdirectory entries in table */
WORD d_NumFileEntries; /* # of file entries in table */
DWORD d_EntryTablePos; /* absolute disk position of entry table */
} Dir;

/* a disk descriptor, appearing once at offset 0 of a disk */
typedef struct
{
DWORD d_Magic; /* magic cookie, must be CompressFS_Magic */
DWORD d_Checksum; /* checksum of entire disk */
DWORD d_DiskSize; /* size in bytes of entire disk */
WORD d_DirEntrySize; /* size of a Dir structure on this disk */
WORD d_FileEntrySize; /* size of a File structure on this disk */
WORD d_SegmentEntrySize; /* size of a Segment structure on this disk */
WORD d_ShortSegmentEntrySize; /* size of a ShortSegment structure */
FILETIME d_CreationTime; /* creation time of disk */
WORD d_Flags; /* control flags for disk, 0 for now */
WORD d_NumRootEntries; /* # of logical volumes on this disk */
DWORD d_EntryTablePos; /* absolute disk position of entry table */
} Disk;

/* magic identifier for CompressFS media */
#define CompressFS_Magic 0xCF5DCF5D

/* maximum # characters in a name string on CompressFS media */
#define CompressFS_MaxNameSize 64


/*****************************************************************************/


#endif /* __COMPRESSFS_H */