commit ae80eadc550f52233dc8214d5428d7b9c58f3b1b Author: John Date: Sat May 17 08:17:12 2025 +1200 Add README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..a58b037 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# 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.