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

Use absolute path to check if FMU exists. #1038

Merged
merged 4 commits into from
Jul 6, 2021

Conversation

AnHeuermann
Copy link
Member

Solves errors like

error:   [addSubModel] file does not exist: "..\..\..\..\..\..\..\..\..\fmus\2.0\cs\win64\Dymola\2019FD01\ControlledTemperature\ControlledTemperature.fmu"

on Windows 10 or

error:   [fmiLogger] module FMICAPI: Could not load the FMU binary: File name is too long.
error:   [instantiate] Could not load "resources/0001_fmu.fmu" which is associated with "model.root.fmu"; it may be corrupted or may not support your platform

on Ubuntu with wine. Example is from https://libraries.openmodelica.org/fmi-crosschecking/OMSimulator/history/build-v2.1.1-58%202021-03-25/wine64/files/20.cs.Dymola.2019FD01.ControlledTemperature/20.cs.Dymola.2019FD01.ControlledTemperature.log.html

Related Issues

Partial fix for #789, but if the absolute path is still to long there is not much I can do about it. The function in question is std::filesystem::exists.

Purpose

Fixes

Approach

Convert all paths passed to addSubModel to an absolute path before doing anything with it.

  Solves errors like
  `error:   [addSubModel] file does not exist: "..\..\..\..\..\..\..\..\..\fmus\2.0\cs\win64\Dymola\2019FD01\ControlledTemperature\ControlledTemperature.fmu"`
@AnHeuermann AnHeuermann self-assigned this Jul 5, 2021
@lochel lochel enabled auto-merge (squash) July 5, 2021 11:51
@AnHeuermann
Copy link
Member Author

AnHeuermann commented Jul 5, 2021

It could be possible for users to change their Windows to accept longer paths: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd

But other then that I can't see much more we can do to solve to long names.

@AnHeuermann
Copy link
Member Author

@lochel
Copy link
Member

lochel commented Jul 6, 2021

@AnHeuermann please have a look. It's not very sophisticated, but might be just good enough.

@lochel lochel merged commit a6d1c8a into OpenModelica:master Jul 6, 2021
@AnHeuermann AnHeuermann deleted the absolutePath branch December 8, 2021 08:35
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 this pull request may close these issues.

2 participants