2025-05-17 08:17:12 +12:00
2025-05-17 08:17:12 +12:00

Dehydrate

Given a source file or folder, creates c++ code to recreate that file/folder. If it's a folder, it recreates the entire tree (all subfolders and files within).

Use:

Usage:
    dehydrate [-s] SOURCEFILE DESTFOLDER      Creates _SOURCEFILE.CPP and _SOURCEFILE.HPP in DESTFOLDER
    dehydrate [-s] SOURCEFOLDER DESTFOLDER    Creates _SOURCEFOLDER.CPP and _SOURCEFOLDER.HPP in DESTFOLDER

    -s = silent (no output)

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.

Description
Convert files on disk to cpp code that recreates that file.
Readme 23 MiB
v11 Latest
2025-05-25 18:29:39 +12:00
Languages
C++ 97.1%
Shell 2.7%
CMake 0.2%