added writePGF

This commit is contained in:
krangelov
2021-09-15 19:58:42 +02:00
parent c6d6914688
commit e00be98ac6
7 changed files with 495 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
#include <math.h>
#include "data.h"
#include "reader.h"
#include "writer.h"
#include "printer.h"
static void
@@ -157,6 +158,33 @@ PgfDB *pgf_read_ngf(const char *fpath,
return NULL;
}
PGF_API
void pgf_write_pgf(const char* fpath,
PgfDB *db, PgfRevision revision,
PgfExn* err)
{
FILE *out = NULL;
PGF_API_BEGIN {
out = fopen(fpath, "wb");
if (!out) {
throw pgf_systemerror(errno, fpath);
}
{
DB_scope scope(db, READER_SCOPE);
ref<PgfPGF> pgf = PgfDB::revision2pgf(revision);
PgfWriter wtr(out, fpath);
wtr.write_pgf(pgf);
}
} PGF_API_END
end:
if (out != NULL)
fclose(out);
}
PGF_API
void pgf_free(PgfDB *db)
{