deco file extraction framework
deco is a Un*x program, written in SUSv3-compliant C99, that is able to extract various archive file formats, with the following features:
Consistent command line interface
Instead of having to remember e. g.
- tar xjf 1.tar.bz2
- unrar x 2.rar
- flac -d 3.flac
- dpkg-deb --extract 4.deb
- deco 1.tar.bz2 2.rar 3.flac 4.deb
and deco extracts them all (provided you’ve also installed the deco-archive package).
Where to extract
- Some extractors extract in the current working directory, others use the directory the archive resides in.
- deco extracts relative to the current working directory, unless you give it the -a (“absolute”) option. See below for details.
- Some extractors delete the archive after successful extraction, others don’t.
- deco preserves the archive after successful extraction, unless you give it the -u (“unlink”) option.
Quiet or verbose?
- Some extractors process the archive verbosely by default and expect you to specify that quiet behavior is wanted. Others do the opposite.
- deco extracts quietly, unless you give it the -v (“verbose”) option.
- Some extractors will leave the partial content extracted so far around if extraction fails. Others will delete it.
- deco will keep partial content, unless you give it the -c (“clean”) option.
Unknown file extensions
- Some extractors refuse to even try extracting anything with an unknown extension.
- deco can force an extractor to handle a file with any name. Use the -e (“extension”) option: deco -e gz myarchive
When you extract an archive that contains multiple files at its top level, you usually want them to be placed in a directory of their own. However, if the archive contains only one file or one big directory, that behavior would be annoying.
The deco extraction algorithm does the right thing automatically: generally, if and only if archive.foo contains multiple files at its top level, a new directory called archive/ is created and the archive gets extracted there.
deco never overwrites files, nor does it need to prompt you for manual conflict resolution.
If the file to be extracted is named foo and a file by that name already exists, the new file will be extracted as 1-foo, if that name also exists, 2-foo, and so on.
Since at the top level only one new file or directory is created (see above), at most this one file will have its name changed like that.
There are extractors that create files with strange permissions. deco can reset these to sensible defaults implied by your current file mode creation mask.
As all the heavy lifting is done in the core algorithm, adding support for new archive formats requires very little work.