EPANET
EPANET copied to clipboard
ENsaveinpfile ignore vertices
The following code ignores saveauxdata
when we call and save with the same inpname
.
https://github.com/OpenWaterAnalytics/EPANET/blob/bbe4fb7a0b183976f06704506a940ed6397f10e6/src/inpfile.c#L37
ENopen('Anytown.inp');
ENsaveinpfile('Anytown.inp');
When the saveinpfile()
function in inpfile.c
opens "Anytown.inp" for writing any existing contents of the file are lost. When saveauxdata()
looks for the [VERTICES], [TAGS]
, etc. sections in "Anytown.inp" it can't find them so no auxilary data gets saved. Two possible solutions for this situation are:
- Just live with it and note somewhere in the docs that this will happen when duplicate file names are used.
- Have
EN_saveinpfile()
issue an error message if the file to be saved has the same name as the file used to open the project.
@LRossman, If we use a temporary tempname
for all epanet input files and then copy the tempname
to the inpname
who user set. What do you think?
Btw, I agree with the two possible solutions above!
@Mariosmsk I don't think just manipulating file names will help. You would have to copy the original input file to a temporary file, write the non-auxilary data in memory to the user-named file, read the auxilary data from the temporary file and write it to the user-named file, and finally delete the temporary file. Seems like a lot of work.
Why can't the app that's calling EN_saveinpfile
call it with a different user-supplied file name and then use a file copy function (not part of the toolkit) to copy its contents into the original .inp
file?
Why can't the app that's calling
EN_saveinpfile
call it with a different user-supplied file name and then use a file copy function (not part of the toolkit) to copy its contents into the original.inp
file?
@LRossman, That we use until now. So we continue to use this. :)
But the solutions above I think it's good both to use in the toolkit.