Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix problems with base_file containing a directory #1371

Merged
merged 10 commits into from
Jan 7, 2024
Merged

Conversation

Randalphwa
Copy link
Collaborator

This PR adds a new function to the ProjectHandler class that retrieves the full path to the output file for the specified form and language. This also eliminates a duplicate single-level folder. E.g., given a project output file called generate and a form base_file called generate/my_form this will remove the duplicate generate folder. The upside is that this will fix the most common error where the folder portion was entered by hand even though it wasn't needed. It will, however, prevent the user from specifying nested folders containing the same name (i.e., generate/generate/my_form won't work if project output directory is set to generate/).

The second part of this PR adds a isGenerating() to App and uses that in FileCodeWriter::WriteFile() to determine whether or not to ask the user permission to create a directory that was specified, but doesn't exist. This allows the code writer to create a missing directory as long as code generation is running from the command line.

See #1366

This serves two purposes: it allows removing all the duplicate code in each
language that effectively does the same thing, and it handles a duplicate
initial folder.
Returning std::pair means a directory can always be returned, and the second
part is a boolean indicating if an output filename was appended.
When generating code from the command line, no UI should be called.
This method provides an accurate check for whether command-line
code generation is under way.
MainApp() should be used rather than flag_no_ui since it's a more accurate
flag as to whether any UI can be used or not.
wxMessageBox() can truncate a long filename, so wxMessageDialog() is
required.
Handle being passed a Project node.
Handle being passed a non-form, non-folder node.
The trailing '/' was removed in order to check for a duplicate folder name,
but was not being correctly added back before the base_file was appended.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant