Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

File extension sanity checks when opening a file #3349

Open
karliss opened this issue May 28, 2024 · 0 comments
Open

File extension sanity checks when opening a file #3349

karliss opened this issue May 28, 2024 · 0 comments

Comments

@karliss
Copy link
Member

karliss commented May 28, 2024

Is your feature request related to a problem? Please describe.

Certain file types need to be opened in certain mode like ihex:// srec:// jar:// and so on. Opening them as file:// will result in completely wrong result.

Describe the solution you'd like

Create a list of typical extensions for the IO modes where it makes sense. And add some sanity checks or warnings if user tries to do something which is probably wrong.

Keep in mind that

  • not all io modes have meaningful extension
  • and sometimes user might want to open a file as raw file even if there is a suitable IO mode
  • some formats with known extensions, might also be often used with wide range of less common extension or no extension at all

While adding this information it might be also useful to add a flag whether io mode expects file at all.

Describe alternatives you've considered

a) show a warning if there is a more likely IO mode for current file extension
b) After user selects a file, automatically switch to more likely IO mode base on extension if there is one. Don't change anything if extension doesn't have any reasonable guesses. Either way they can still override the IO mode afterwards if guess was wrong or they want to do something unusual.
c) secretly switch the mode under the hood when IO mode is set to file://
d) when opening a file directly without the initial window use the best guess for choosing IO mode.

Additional context

I am unsure about approach c). In ideal world user wouldn't need to manually choose anything, on other hand the file:// IO mode has a specific meaning. Changing the meaning behind the scenes can cause more misunderstandings, and it's less clear how to override things when guesses aren't good enough. b) is probably better as it achieves similar thing while being more explicit to the user of what's happening.

Partially related problem #2204 , but that one might require a more custom solution compared to the file extension check suggested here.

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

No branches or pull requests

1 participant