Skip to content

Add a parameter to FileDialogManager.SaveFile to append an extension. - #7074

Open
whatston3 wants to merge 4 commits into
space-wizards:masterfrom
whatston3:2026-09-07-save-extension
Open

whatston3 wants to merge 4 commits into
space-wizards:masterfrom
whatston3:2026-09-07-save-extension

Conversation

@whatston3

Copy link
Copy Markdown
Contributor

Title.

Adds an optional parameter called appendExtension to FileDialogManager.SaveFile, defaulting to false (preserving existing behaviour - shouldn't break anything as-is). When set to true, if a file is selected for saving, the extension is added to the file if the entered file name:

  1. Doesn't exist,
  2. Doesn't have an extension already,
  3. Wasn't selected with a wildcard filter.

IFileDialogManagerImplementation.OpenFile, SaveFile edited to receive the filter index to get the expected file extension to append to the file.

To test:

  1. Checkout 2026-09-07-append-extension off of my ss14 repo
  2. Build and run (might need to add me as an RT remote to get the submodule, but it's the head of this PR.
  3. Run golobby, enter the character menu.
  4. Export a character to "bababooey", you should write to "bababooey.yml".
  5. Export a character to "plonk.yml", you should write to "plonk.yml".
  6. Export a character to "funny.txt", you should write to "funny.txt".
  7. Rename "funny.txt" to "funny" and save to "funny" - you should rewrite over "funny", and not create a file called "funny.yml".

Comment on lines +89 to +96
{
var firstExtension = filters.Groups[filter].Extensions[0];
if (firstExtension != "*")
{
name += "." + firstExtension;
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I high or is this possible to sandbox break because filedialogfilters are entirely user input and we're manually constructing the path here?

@whatston3 whatston3 Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extension groups shouldn't be user input - in the existing test cases, that should be "yml" and "csv".
I mean, they could be, but why would you do that?

[If it is a problem, and if it can be fixed, I'm all ears.]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have any existing restrictions around file formats, e.g. if some fork wants to use their own format, or wants their own tigher whitelist, which I don't know if we want to support or not. it may become a problem when video resources get implemented so maybe better to just allow any extensions to be used for filters.

Comment thread RELEASE-NOTES.md Outdated
@Mackamuir

Copy link
Copy Markdown

Epic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants