Add parent directory creation to write_to_file function
This commit adds the ability to create parent directories if they don't exist before writing a file in the write_to_file function. Additionally, an integration test has been changed to validate the behavior of the updated write_to_file function with parent directory creation.
This feature enables preserving the hierarchical structure of C/C++ projects where header files with the same name exist in different folders when generating bindings.
Additionally, this enhancement could have been implemented as an optional parameter if desired. If preferred, I can try refactor the changes to incorporate the functionality as an optional parameter.
@emilio
Is there any use case where calling create_dir_all before write_to_file is not enough?
I thought it would be nicer to solve this by using the bindgen library. At the same time, in the bindgen CLI usage, there is no need for an additional operation like "mkdirs" command or "--create_dir_all" as the output is directly given. In this specific use case, simply outputting the generated bindings without performing a separate directory creation step is sufficient.
Even though I understand your point, I think this is not a strong enough reason to add this feature. That being said, I'll defer this to @emilio as he might think otherwise.