SQLite Archiver

Check-in [d8653ef491]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Change the name from "SFA" to "SQLAR" since it turns out that SFA is also the name of a French sewage treatment appliance.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d8653ef49178c25174e5b705ef0bd1a9e3505bf9
User & Date: drh 2014-05-22 11:54:53.807
Context
2014-06-02
15:50
Update the built-in SQLite to the latest 3.8.5 beta from upstream. check-in: ff0460752a user: drh tags: trunk
2014-05-22
11:54
Change the name from "SFA" to "SQLAR" since it turns out that SFA is also the name of a French sewage treatment appliance. check-in: d8653ef491 user: drh tags: trunk
2014-05-15
11:55
Change the title on the README.md page. check-in: 3d0e7db437 user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Makefile.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/make

CC = gcc -g -I.
ZLIB = -lz
SQLITE_OPT = -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION

all: sfa
	

sfa:	sfa.c sqlite3.o
	$(CC) -o sfa sfa.c sqlite3.o $(ZLIB)

sqlite3.o:	sqlite3.c sqlite3.h
	$(CC) -c sqlite3.c $(SQLITE_OPT) sqlite3.c






|


|
|



1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/make

CC = gcc -g -I.
ZLIB = -lz
SQLITE_OPT = -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION

all: sqlar
	

sqlar:	sqlar.c sqlite3.o
	$(CC) -o sqlar sqlar.c sqlite3.o $(ZLIB)

sqlite3.o:	sqlite3.c sqlite3.h
	$(CC) -c sqlite3.c $(SQLITE_OPT) sqlite3.c
Changes to README.md.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<h1 align="center">SFA - SQLite File Archiver</h1>

This repository contains sources for a proof-of-concept "SQLite File Archiver"
program.  This program (named "sfa") operates much like "zip", except that
the compressed archive it builds is stored in an SQLite database instead
of a ZIP archive.

The motivation for this is to see how much larger an SQLite database file
is compared to a ZIP archive containing the same content.  The answer depends
on the filenames, but 2% seems to be a reasonable guess.  In other words,
storing files as compressed blobs in an SQLite database file results in a 
file that is only about 2% larger than storing those same files in a ZIP
archive using the same compression.

## Compiling

On unix, just type "make".  The SQLite sources are included.  The zlib
compression library is needed to build.

## Usage

To create an archive:

        sfa ARCHIVE FILES...

All files named in FILES... will be added to the archive.  If another file
with the same name already exists in the archive, it is replaced.  If any
of the named FILES is a directory, that directory is scanned recursively.

To see the contents of an archive:

        sfa -l ARCHIVE

To extract the contents of an archive:

        sfa -x ARCHIVE [FILES...]

If a FILES argument is provided, then only the named files are extracted.
Without a FILES argument, all files are extracted.

All commands can be supplemented with -v for verbose output. For example:

        sfa -v ARCHIVE FILES..
        sfa -lv ARCHIVE
        sfa -xv ARCHIVE

File are normally compressed using zlib prior to being stored as BLOBs in
the database.  However, if the file is incompressible or if the -n option
is used on the command-line, then the file is stored in the database exactly
as it appears on disk, without compression.
    
## Storage

The database schema looks like this:

        CREATE TABLE sfa(
          name TEXT PRIMARY KEY,  -- name of the file
          mode INT,               -- access permissions
          mtime INT,              -- last modification time
          sz INT,                 -- original file size
          data BLOB               -- compressed content
        );
        
Both directories and empty files have sfa.sz==0.  Directories can be
distinguished from empty files because directories have sfa.data IS NULL.
The file is compressed if length(sfa.blob)<sfa.sz and is stored
as plaintext if length(sfa.blob)==sfa.sz.
|

|
|



















|







|



|






|
|
|










|







|
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<h1 align="center">SQLAR - SQLite Archiver</h1>

This repository contains sources for a proof-of-concept "SQLite Archiver"
program.  This program (named "sqlar") operates much like "zip", except that
the compressed archive it builds is stored in an SQLite database instead
of a ZIP archive.

The motivation for this is to see how much larger an SQLite database file
is compared to a ZIP archive containing the same content.  The answer depends
on the filenames, but 2% seems to be a reasonable guess.  In other words,
storing files as compressed blobs in an SQLite database file results in a 
file that is only about 2% larger than storing those same files in a ZIP
archive using the same compression.

## Compiling

On unix, just type "make".  The SQLite sources are included.  The zlib
compression library is needed to build.

## Usage

To create an archive:

        sqlar ARCHIVE FILES...

All files named in FILES... will be added to the archive.  If another file
with the same name already exists in the archive, it is replaced.  If any
of the named FILES is a directory, that directory is scanned recursively.

To see the contents of an archive:

        sqlar -l ARCHIVE

To extract the contents of an archive:

        sqlar -x ARCHIVE [FILES...]

If a FILES argument is provided, then only the named files are extracted.
Without a FILES argument, all files are extracted.

All commands can be supplemented with -v for verbose output. For example:

        sqlar -v ARCHIVE FILES..
        sqlar -lv ARCHIVE
        sqlar -xv ARCHIVE

File are normally compressed using zlib prior to being stored as BLOBs in
the database.  However, if the file is incompressible or if the -n option
is used on the command-line, then the file is stored in the database exactly
as it appears on disk, without compression.
    
## Storage

The database schema looks like this:

        CREATE TABLE sqlar(
          name TEXT PRIMARY KEY,  -- name of the file
          mode INT,               -- access permissions
          mtime INT,              -- last modification time
          sz INT,                 -- original file size
          data BLOB               -- compressed content
        );
        
Both directories and empty files have sqlar.sz==0.  Directories can be
distinguished from empty files because directories have sqlar.data IS NULL.
The file is compressed if length(sqlar.blob)<sqlar.sz and is stored
as plaintext if length(sqlar.blob)==sqlar.sz.
Name change from sfa.c to sqlar.c.