Add README.md

This commit is contained in:
John 2025-05-17 08:17:12 +12:00
commit ae80eadc55

39
README.md Normal file
View File

@ -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.