Dehydrate
Installation
Automated system-wide installation:
curl -fsSL https://gitea.jde.nz/public/dehydrate/releases/download/latest/install.sh | bash
To download just the dehydrate executable:
curl -fsSL -o dehydrate https://gitea.jde.nz/public/dehydrate/releases/download/latest/dehydrate.amd64 && chmod a+x bb64
How it Works
Dehydrate converts existing files to C++ source code which can be used to recreate the original files. Works on individual files or entire directory trees.
Usage: dehydrate [OPTIONS] SOURCE DEST
Options:
-s Silent mode (no output)
-u Update dehydrate to the latest version
Examples:
dehydrate file.txt output/ Creates _file.txt.cpp and _file.txt.hpp in output/
dehydrate src/ output/ Creates _src.cpp and _src.hpp in output/
dehydrate -u Updates dehydrate to the latest version
All c++ code produced is in namespace recreate_{SOURCEFILE|SOURCEFOLDER}
When the source is a file, the C++ function created is:
bool recreate_file(std::string destination_folder);
The path is the full path to the destination folder, excluding the filename. The original filename is used. If a file exists at that location: The hash of the content is compared, and the file is overwritten if the hash is different, otherwise left unchanged. If there is no file: SOURCEFILE is written in destination_folder.
When the source is a folder, the C++ function created is:
bool recreate_tree(std::string destination_folder);
The destination_folder (and any needed subfolders) are created if they don't exist. The contents of the original SOURCEFOLDER are recreated inside destination_folder, overwriting any existing content in that folder if the hash of the individual file is different than existing content, or if the file doesn't exist.
In both cases, unless in silent mode, confirmation is displayed for each file, showing the existing and new hash, and whether the file was updated or not.