Skip to content

Commit

Permalink
Add a new pattern or use an existing pattern - EN_loadpatternfile
Browse files Browse the repository at this point in the history
Co-Authored-By: Lew Rossman <[email protected]>
  • Loading branch information
Mariosmsk and LRossman committed Aug 1, 2024
1 parent 17b14e2 commit b16dacb
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/epanet.c
Original file line number Diff line number Diff line change
Expand Up @@ -4538,16 +4538,14 @@ int DLLEXPORT EN_loadpatternfile(EN_Project p, const char *filename, const char
file = fopen(filename, "r");
if (file == NULL) return 302;

// Add the new pattern
if ((err = EN_addpattern(p, id)) != 0) {
fclose(file);
return err;
}

// Get the index of the newly added pattern
if ((err = EN_getpatternindex(p, id, &i)) != 0) {
fclose(file);
return err;
// Add a new pattern or use an existing pattern.
err = EN_getpatternindex(p, id, &i);
if (err == 205) {
if ((err = EN_addpattern(p, id)) != 0) {
fclose(file);
return err;
}
i = p->network.Npats;
}

// Read pattern values
Expand Down

0 comments on commit b16dacb

Please sign in to comment.