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

Error 'Invalid argument' when output path contains backslashes on Windows #63

Closed
w1th0utnam3 opened this issue Apr 20, 2020 · 0 comments · Fixed by #64
Closed

Error 'Invalid argument' when output path contains backslashes on Windows #63

w1th0utnam3 opened this issue Apr 20, 2020 · 0 comments · Fixed by #64

Comments

@w1th0utnam3
Copy link

w1th0utnam3 commented Apr 20, 2020

On Windows it's common that paths contain backslashes (although forward slashes are also supported in many places). However, when I pass a path to a save_to_ function that contains backslashes, I get the following error:

gnuplot> set output "Z:\temp\out\energy\energy3d_test\plot.pdf"
                                                               ^
         line 0:          cannot open file; output not changed
system error: Invalid argument

Currently, I use the following workaround in my code

let output_file = output_path.join("plot.pdf");
if cfg!(windows) {
    // On Windows, gnuplot doesn't accept any backslashes in the path
    let output_file = output_file.to_str().unwrap().replace("\\", "/");
    fg.save_to_pdf(&output_file, 12, 8).unwrap();
} else {
    fg.save_to_pdf(&output_file, 12, 8).unwrap();
}

Either the backslashes have to be somehow escaped when passing them to the gnuplot executable or it doesn't support backslashes in the path at all. In any case, I think this should be handled by this library and not by user code. Unfortunately I don't have time at the moment to investigate this further.

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 a pull request may close this issue.

1 participant