LANDIS-II-Foundation / Extension-Base-BDA

Biological Disturbance Agent extension for LANDIS-II
https://sites.google.com/site/landismodel/extensions/base-biological-disturbance-agents
Apache License 2.0
3 stars 6 forks source link

Log file without explicit directory path causes Exception #8

Open IvanPizhenko opened 3 years ago

IvanPizhenko commented 3 years ago

I have following in the BDA config file:

LandisData "Base BDA"

...

LogFile     output_BDA_log.csv

And this causes me an error:

Internal error occurred within the program:
Path cannot be the empty string or all whitespace.
Parameter name: path

Stack trace:
at System.IO.Directory.CreateDirectory(String path)
at Landis.Extension.BaseBDA.MetadataHandler.InitializeMetadata(Int32 Timestep, String severityMapFileName, String srdMapFileName, String nrdMapFileName, String logFileName, IEnumerable`1 manyAgentParameters, ICore mCore)
at Landis.Extension.BaseBDA.PlugIn.Initialize()
at Landis.Model.InitExtensions(ExtensionMain[] extensions)
at Landis.Model.Run(String scenarioPath, IUserInterface ui)
at Landis.App.Main(String[] args) in D:\CGAProjects\Rob\LANDIS_FINAL\GitHubRepo\Core-Model-v7\Tool-Console\src\App.cs:line 99

I think this line of code causes the issue (in the MetadataHandler.cs):

            System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(logFileName));

if System.IO.Path.GetDirectoryName(logFileName) just returns empty string or all whitespaces, the directory should not be created.

IvanPizhenko commented 3 years ago

I can submit PR that fixes this.

IvanPizhenko commented 3 years ago

I've also found a workaround, it is use .\logfile.txt instead of just logfile.txt, but still I just can submit a small fix for this.

IvanPizhenko commented 3 years ago

Please look at PR #9