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

Invalid file path when starting Solvespace with argument (Windows, cmd and drag-and-drop) #622

Closed
gnbl opened this issue Jun 1, 2020 · 3 comments · Fixed by #740
Closed

Comments

@gnbl
Copy link

gnbl commented Jun 1, 2020

This is SolveSpace version 3.0~225f82a2 on Windows 10 (from https://ci.appveyor.com/api/buildjobs/g2waan8v16gv22jc/artifacts/build%2Fbin%2FDebug%2Fsolvespace.exe)

  1. Start program / open file by drag-dropping the file on the executable.
  2. "File > Save As..." fails without error (file chooser dialog does not open)
  3. Window title bar and "File > Open Recent" entries show filename as \\?\<path>
@gnbl
Copy link
Author

gnbl commented Jun 3, 2020

Same behavior when running solvespace.exe <path> in cmd.exe.

@gnbl gnbl changed the title Invalid file path when dragging .slvs file on .exe (Windows drag and drop argument handling) Invalid file path when starting Solvespace with argument (Windows, cmd and drag-and-drop) Jun 3, 2020
@gnbl
Copy link
Author

gnbl commented Jun 3, 2020

@whitequark whitequark added this to the 3.0 milestone Jun 23, 2020
@ruevs
Copy link
Member

ruevs commented Oct 16, 2020

The problem is caused by this code:

expanded.raw = "\\\\?\\" + expanded.raw;

When a file is passed in as a command line argument the parsing on Windows adds the raw handling prefix \\?\ to the path. In other words the path becomes:
\\?\C:\Users\...
instead of:
C:\Users\...
However the file Open/Save/Save As dialog boxes do not seem to like this prefix (the path is stored in the lpstrFile member of the OPENFILENAMEA structure

When a file is opened with the "File | Open..." or "Open Recent" dialog boxes on the other hand the ofn structure contains a normal path (because Platform::Path saveFile does) - and that is why it works.

The easiest way would be to comment out

expanded.raw = "\\\\?\\" + expanded.raw;
but we will lose the ability to open files from long paths (>MAX_PATH). Otherwise I will have to think about it some more how to keep saveFile a plain path.

ruevs added a commit to ruevs/solvespace that referenced this issue Oct 16, 2020
…rgument is used.

`GetSaveFileNameA` `OPENFILENAMEA` does not like UNC ( "\\\\?\\C:\\..." ) file prefixes in `lpstrFile`.
Work around it by not `Expand`-ing parameters passed on the command line too early.

The only user visible change is that "File|Open Recent" will show items as they
were passed instead of expanded to full path for example:
"..\..\NURBSTests\Intersection2.slvs"

Fixes: solvespace#622
phkahler pushed a commit that referenced this issue Oct 16, 2020
…rgument is used.

`GetSaveFileNameA` `OPENFILENAMEA` does not like UNC ( "\\\\?\\C:\\..." ) file prefixes in `lpstrFile`.
Work around it by not `Expand`-ing parameters passed on the command line too early.

The only user visible change is that "File|Open Recent" will show items as they
were passed instead of expanded to full path for example:
"..\..\NURBSTests\Intersection2.slvs"

Fixes: #622
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants