gnormal / gnorm

A database-first code generator for any language
https://gnorm.org
Other
487 stars 40 forks source link

atomic file generation #24

Closed natefinch closed 6 years ago

natefinch commented 6 years ago

This change ensures that we only overwrite files if generation succeeds. Previously we were opening the file and truncating before doing the generation. Now we generate in memory and then write out to disk. For extra security, use an atomic writefile that ensures we won't write half a file.

In addition, refactor the generation so the meat of the code is the same for everything.