From 3ea8ebfaf57ab061f18f2838f6599d10a339d59b Mon Sep 17 00:00:00 2001 From: ruevs Date: Fri, 16 Oct 2020 16:54:21 +0300 Subject: [PATCH] Win32: Fix "File|Open...", "Save" and "Save As" when a command line argument 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: https://github.com/solvespace/solvespace/issues/622 --- src/platform/entrygui.cpp | 2 +- src/platform/platform.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/entrygui.cpp b/src/platform/entrygui.cpp index 30fd4438..397831ac 100644 --- a/src/platform/entrygui.cpp +++ b/src/platform/entrygui.cpp @@ -21,7 +21,7 @@ int main(int argc, char** argv) { dbp("Only the first file passed on command line will be opened."); } - SS.Load(Platform::Path::From(args.back()).Expand(/*fromCurrentDirectory=*/true)); + SS.Load(Platform::Path::From(args.back())); } Platform::RunGui(); diff --git a/src/platform/platform.cpp b/src/platform/platform.cpp index a0809821..f025c861 100644 --- a/src/platform/platform.cpp +++ b/src/platform/platform.cpp @@ -401,7 +401,7 @@ FILE *OpenFile(const Platform::Path &filename, const char *mode) { ssassert(filename.raw.length() == strlen(filename.raw.c_str()), "Unexpected null byte in middle of a path"); #if defined(WIN32) - return _wfopen(Widen(filename.Expand().raw).c_str(), Widen(mode).c_str()); + return _wfopen(Widen(filename.Expand(/*fromCurrentDirectory=*/true).raw).c_str(), Widen(mode).c_str()); #else return fopen(filename.raw.c_str(), mode); #endif