diff options
author | Thomas White <taw@physics.org> | 2023-12-22 11:46:09 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2024-01-30 10:35:03 +0100 |
commit | 9cb19d72dffdb5c1b802ba14c971a21e8ca2982d (patch) | |
tree | ddf08e889bc0bad61f8b0666f1eebc24f11e5e87 /libcrystfel/src/datatemplate.c | |
parent | c572a2cabca0339e633eb6ca98fbf0a3bed53497 (diff) |
Add data_template_write_to_fh and stream_write_data_template
Diffstat (limited to 'libcrystfel/src/datatemplate.c')
-rw-r--r-- | libcrystfel/src/datatemplate.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c index e480779c..c11ec89d 100644 --- a/libcrystfel/src/datatemplate.c +++ b/libcrystfel/src/datatemplate.c @@ -2304,14 +2304,10 @@ static const char *str_dim(int dim) } -int data_template_write_to_file(const DataTemplate *dtempl, const char *filename) +int data_template_write_to_fh(const DataTemplate *dtempl, FILE *fh) { - FILE *fh; int i; - fh = fopen(filename, "w"); - if ( fh == NULL ) return 1; - /* Basic top-level parameters */ switch ( dtempl->wavelength_unit ) { @@ -2643,11 +2639,22 @@ int data_template_write_to_file(const DataTemplate *dtempl, const char *filename fprintf(fh, "\n"); } - fclose(fh); return 0; } +int data_template_write_to_file(const DataTemplate *dtempl, const char *filename) +{ + FILE *fh; + int r; + fh = fopen(filename, "w"); + if ( fh == NULL ) return 1; + r = data_template_write_to_fh(dtempl, fh); + fclose(fh); + return r; +} + + static void add_group_info(struct dg_group_info *ginfo, int *ppos, struct panel_group_template *group, int serial, int level, int c_mul) |