modelica-tools / csv-compare

Tool to compare curves from one csv files with curves from other csv files using an adjustable tolerance
https://www.modelica.org
BSD 3-Clause "New" or "Revised" License
26 stars 15 forks source link

Compare.exe does not accept relative .csv files from current working directory #56

Closed adriantirea closed 4 years ago

adriantirea commented 5 years ago
> compare.exe file.csv file_base.csv
2019-07-18Z15:00:35 [       Error ] Exception during run: The path is not of a legal form.

The problem is that it tries to deduce the report directory from the first .csv file. Here there is no leading directory so Path.GetDirectoryName(options.Items[0]) is empty string. Then Path.GetFullPath("") causes an exception. You should deal with this case and in case of empty string passed to GetFullPathWithEndingSlashes you should ask for current working directory Path.GetFullPath(".")

Next is the current logic from Program.cs that needs fixing:

options.ReportDir = GetFullPathWithEndingSlashes(Path.GetDirectoryName(options.Items[0]));
....
private static string GetFullPathWithEndingSlashes(string input)
        {
            string fullPath = Path.GetFullPath(input);
            return fullPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) + Path.DirectorySeparatorChar;
        }
beutlich commented 4 years ago

Can reproduce.