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

Support forward slashes (not just backslashes) in .ksy paths on Windows #52

Closed
generalmimon opened this issue Aug 15, 2022 · 0 comments
Closed
Labels

Comments

@generalmimon
Copy link
Member

generalmimon commented Aug 15, 2022

Right now, it's effectively only possible to use backslashes (C:\path\to\spec.ksy) to specify the full path to a .ksy file on Windows, which is quite restrictive - basically all programs on Windows accept paths with forward slashes, so you get used to being able to use them.

I also don't think that the Windows users who tried to use forward slash .ksy paths and got the following cryptic error because of it:

C:/temp/kaitai_struct/visualizer/lib/kaitai/struct/visualizer/ksy_compiler.rb:84:in `block (2 levels) in compile_formats':
	undefined method `[]' for nil:NilClass (NoMethodError)

...had any clue what's going on and that it's caused by the use of forward slashes - this just typically doesn't occur to you when you can use forward slashes pretty much everywhere. So they would probably conclude that ksv and ksdump can't be used on Windows and maybe resort to installing it in WSL.

This bug is caused by the fact that the compiler's --ksc-json-output uses backslash paths as JSON keys on Windows, so when KSV tries to use the forward slash path (directly from the CLI argument provided by the user) as the key on this line:

..., it can't find anything and crashes.

The solution is to convert the path to use backslashes and also try using it as the key (in case the direct use doesn't find anything).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant