File: afmw-spec.c

package info (click to toggle)
gwyddion 2.62-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 51,952 kB
  • sloc: ansic: 398,486; python: 7,877; sh: 5,492; makefile: 4,723; xml: 3,883; cpp: 1,969; pascal: 418; perl: 154; ruby: 130
file content (664 lines) | stat: -rw-r--r-- 20,310 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
/*
 *  $Id: afmw-spec.c 21495 2018-10-19 16:11:08Z yeti-dn $
 *  Copyright (C) 2018 David Necas (Yeti).
 *  E-mail: yeti@gwyddion.net.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301, USA.
 */

/**
 * [FILE-MAGIC-FREEDESKTOP]
 * <mime-type type="application/x-afm-workshop-spectra">
 *   <comment>AFM Workshop spectroscopy data</comment>
 *   <magic priority="80">
 *     <match type="string" offset="0" value="Force-Distance Curve">
 *       <match type="string" offset="20:24" value="File format:\t">
 *         <match type="string" offset="30:48" value="Date:\t"/>
 *       </match>
 *     </match>
 *   </magic>
 * </mime-type>
 **/

/**
 * [FILE-MAGIC-USERGUIDE]
 * AFM Workshop spectroscopy
 * .csv
 * SPS
 **/

#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <libgwyddion/gwymacros.h>
#include <libgwyddion/gwymath.h>
#include <libgwyddion/gwyutils.h>
#include <libprocess/datafield.h>
#include <libgwymodule/gwymodule-file.h>
#include <app/data-browser.h>
#include <app/gwymoduleutils-file.h>

#include "err.h"

#define MAGIC1 "Force-Distance Curve"
#define MAGIC1_SIZE (sizeof(MAGIC1)-1)

typedef struct {
    gchar *name;       /* Extend Z-Sense, Retract T-B, ... */
    GwySIUnit *unit;   /* unit */
    gdouble magnitude; /* factor for data conversion */
} AFMWColumn;

typedef struct {
    gdouble x;
    gdouble y;
    guint ncolumns;
    guint nrows;
    AFMWColumn *columns;
    gdouble *data;
} AFMWSingleFile;

typedef struct {
    gchar *filename;
    gint id;
    GTimeVal datetime;
} AFMWFileInfo;

typedef struct {
    GwySpectra **spectra;
    AFMWSingleFile *template;
} AFMWSpectraSet;

static gboolean        module_register          (void);
static gint            afmw_detect              (const GwyFileDetectInfo *fileinfo,
                                                 gboolean only_name);
static GwyContainer*   afmw_load                (const gchar *filename,
                                                 GwyRunType mode,
                                                 GError **error);
static gboolean        check_compatibility      (const AFMWSingleFile *afmwfile,
                                                 const AFMWSingleFile *template);
static void            add_curves_to_spectra_set(AFMWSpectraSet *specset,
                                                 AFMWSingleFile *afmwfile);
static AFMWSingleFile* read_one_afmw_file       (const gchar *filename,
                                                 GError **error);
static gchar**         find_all_file_names      (const gchar *filename);
static void            afmw_single_file_free    (AFMWSingleFile *afmwfile);

static GwyModuleInfo module_info = {
    GWY_MODULE_ABI_VERSION,
    &module_register,
    N_("Imports AFM Workshop spectrum files."),
    "Yeti <yeti@gwyddion.net>",
    "1.0",
    "David Nečas (Yeti)",
    "2018",
};

GWY_MODULE_QUERY2(module_info, afmw_spec)

static gboolean
module_register(void)
{
    gwy_file_func_register("afmw_spec",
                           N_("AFM Workshop spectrum files (.csv)"),
                           (GwyFileDetectFunc)&afmw_detect,
                           (GwyFileLoadFunc)&afmw_load,
                           NULL,
                           NULL);

    return TRUE;
}

static const guchar*
find_field_in_head(const GwyFileDetectInfo *fileinfo,
                   const guchar *p,
                   const gchar *s)
{
    p = gwy_memmem(p, fileinfo->buffer_len - (p - fileinfo->head),
                   s, strlen(s));
    if (p && (p == fileinfo->head || *(p-1) == '\r' || *(p-1) == '\n'))
        return p;
    return NULL;
}

static gint
afmw_detect(const GwyFileDetectInfo *fileinfo,
            gboolean only_name)
{
    const guchar *p;

    if (only_name)
        return 0;

    p = fileinfo->head;
    if (memcmp(p, MAGIC1, MAGIC1_SIZE) != 0)
        return 0;
    p += MAGIC1_SIZE;

    if (*p != '\r' && *p != '\n')
        return 0;
    while (*p == '\r' || *p == '\n')
        p++;

    if (find_field_in_head(fileinfo, p, "File Format:\t")
        && find_field_in_head(fileinfo, p, "Date:\t")
        && find_field_in_head(fileinfo, p, "Time:\t")
        && find_field_in_head(fileinfo, p, "Mode:\t")
        && find_field_in_head(fileinfo, p, "Point:\t"))
        return 90;

    return 0;
}

static GwyContainer*
afmw_load(const gchar *filename,
          G_GNUC_UNUSED GwyRunType mode,
          GError **error)
{
    GwyContainer *container = NULL;
    gchar **filenames;
    AFMWSpectraSet specset;
    AFMWSingleFile *afmwfile;
    GQuark quark;
    guint i, j;

    gwy_clear(&specset, 1);
    filenames = find_all_file_names(filename);
    /* When we cannot enumerate files, just create a list containing the single
     * file name we were given explicitly. */
    if (!filenames) {
        filenames = g_new0(gchar*, 2);
        filenames[0] = g_strdup(filename);
    }

    /* Use the file the user selected as the template. */
    if (!(specset.template = read_one_afmw_file(filename, error)))
        goto fail;

    for (i = 0; filenames[i]; i++) {
        if (!(afmwfile = read_one_afmw_file(filenames[i], error))) {
            g_warning("Cannot read associated file %s.", filenames[i]);
            continue;
        }

        if (check_compatibility(afmwfile, specset.template))
            add_curves_to_spectra_set(&specset, afmwfile);
        /* Simply skip incompatible files. */
        afmw_single_file_free(afmwfile);
    }

    for (i = j = 0; i < specset.template->ncolumns; i++) {
        if (!specset.spectra[i])
            continue;

        if (!container)
            container = gwy_container_new();
        quark = gwy_app_get_spectra_key_for_id(j);
        gwy_container_set_object(container, quark, specset.spectra[i]);
        j++;
    }

    if (!container)
        err_NO_DATA(error);

fail:
    if (specset.template) {
        if (specset.spectra) {
            for (i = 0; i < specset.template->ncolumns; i++)
                GWY_OBJECT_UNREF(specset.spectra[i]);
            g_free(specset.spectra);
        }
        afmw_single_file_free(specset.template);
    }
    g_strfreev(filenames);

    return container;
}

static gboolean
check_compatibility(const AFMWSingleFile *afmwfile,
                    const AFMWSingleFile *template)
{
    const AFMWColumn *datcolumn, *tmplcolumn;
    guint i;

    if (afmwfile->ncolumns != template->ncolumns)
        return FALSE;
    for (i = 0; i < template->ncolumns; i++) {
        datcolumn = afmwfile->columns + i;
        tmplcolumn = template->columns + i;
        if (!gwy_strequal(datcolumn->name, tmplcolumn->name)
            || !gwy_si_unit_equal(datcolumn->unit, tmplcolumn->unit))
            return FALSE;
    }
    return TRUE;
}

static inline void
strip_space_back(gchar *end, gchar *beg)
{
    do {
        *end = '\0';
        end--;
    } while (end >= beg && g_ascii_isspace(*end));
}

static void
parse_column_header(gchar *colname, AFMWColumn *column)
{
    gchar *p, *q, *unit;
    gint power10;

    column->name = colname;
    column->unit = NULL;
    column->magnitude = 1;

    if ((p = strchr(colname, '('))) {
        if ((q = strchr(p+1, ')'))) {
            unit = p+1;
            strip_space_back(p, colname);
            *q = '\0';
            column->unit = gwy_si_unit_new_parse(unit, &power10);
            column->magnitude = pow10(power10);
        }
        else {
            g_warning("Column header %s has only opening (.", colname);
        }
    }
    if (!column->unit)
        column->unit = gwy_si_unit_new(NULL);
}

static void
add_curves_to_spectra_set(AFMWSpectraSet *specset,
                          AFMWSingleFile *afmwfile)
{
    guint i, j, ncolumns, nrows;
    gdouble real, off;
    gboolean reversed;
    gdouble *data = afmwfile->data, *d;
    GwyDataLine *dline;
    GwySpectra *spec;
    const AFMWColumn *abscissa = NULL, *ordinate;

    ncolumns = afmwfile->ncolumns;
    nrows = afmwfile->nrows;
    /* Columns that are not spectra values remain NULL later. */
    if (!specset->spectra)
        specset->spectra = g_new0(GwySpectra*, ncolumns);

    reversed = FALSE;
    for (i = 0; i < ncolumns; i++) {
        /* Check if the column is Z-Sense, i.e. abscissa.  */
        if (gwy_stramong(afmwfile->columns[i].name,
                         "Extend Z-Sense", "Retract Z-Sense",
                         NULL)) {
            abscissa = afmwfile->columns + i;
            real = data[i + ncolumns*(nrows - 1)];
            off = data[i];
            if (real < off) {
                GWY_SWAP(gdouble, real, off);
                reversed = TRUE;
            }
            real -= off;
            continue;
        }
        /* Otherwise it must be ordinate. */
        ordinate = afmwfile->columns + i;
        if (!abscissa) {
            g_warning("Ordinate column %s found before any abscissa.",
                      ordinate->name);
            continue;
        }

        dline = gwy_data_line_new(nrows, real, FALSE);
        gwy_data_line_set_offset(dline, off);
        gwy_si_unit_assign(gwy_data_line_get_si_unit_x(dline), abscissa->unit);
        gwy_si_unit_assign(gwy_data_line_get_si_unit_y(dline), ordinate->unit);
        d = gwy_data_line_get_data(dline);
        if (reversed) {
            for (j = 0; j < nrows; j++)
                d[nrows-1 - j] = data[i + j*ncolumns];
        }
        else {
            for (j = 0; j < nrows; j++)
                d[j] = data[i + j*ncolumns];
        }

        if (!(spec = specset->spectra[i])) {
            spec = specset->spectra[i] = gwy_spectra_new();
            gwy_si_unit_set_from_string(gwy_spectra_get_si_unit_xy(spec), "m");
            gwy_spectra_set_title(spec, ordinate->name);
            gwy_spectra_set_spectrum_x_label(spec, abscissa->name);
            gwy_spectra_set_spectrum_y_label(spec, ordinate->name);
        }

        gwy_spectra_add_spectrum(specset->spectra[i], dline,
                                 afmwfile->x, afmwfile->y);
        g_object_unref(dline);
    }
}

static AFMWSingleFile*
read_one_afmw_file(const gchar *filename, GError **error)
{
    AFMWSingleFile *afmwfile;
    GError *err = NULL;
    gsize size;
    gchar *buf, *line, *p, *sep, **colnames;
    GArray *data = NULL;
    guint i;

    gwy_debug("reading %s", filename);
    if (!g_file_get_contents(filename, &buf, &size, &err)) {
        err_GET_FILE_CONTENTS(error, &err);
        return NULL;
    }
    afmwfile = g_new0(AFMWSingleFile, 1);

    p = buf;
    if (memcmp(p, MAGIC1, MAGIC1_SIZE) != 0) {
        err_FILE_TYPE(error, "AFM Workshop SPM");
        goto fail;
    }

    /* Header */
    while ((line = gwy_str_next_line(&p)) && *line)
        ;

    /* Info */
    while ((line = gwy_str_next_line(&p)) && *line) {
        sep = strchr(line, '\t');
        if (!sep || sep == line)
            continue;
        *sep = '\0';
        if (*(sep-1) == ':')
            *(sep-1) = '\0';
        sep++;
        if (g_str_has_prefix(line, "X, ") || g_str_has_prefix(line, "Y, ")) {
            gint power10;
            GwySIUnit *unit = gwy_si_unit_new_parse(line + 3, &power10);
            gdouble v = pow10(power10) * g_ascii_strtod(sep, NULL);

            if (line[0] == 'Y') {
                afmwfile->y = v;
                gwy_debug("y %g", afmwfile->y);
            }
            else {
                afmwfile->x = v;
                gwy_debug("x %g", afmwfile->x);
            }
            g_object_unref(unit);
        }
        /* We do not care about the other fields because we cannot do
         * anything meaningful with them. */
    }

    /* Data */
    if (!(line = gwy_str_next_line(&p)) || !*line) {
        err_NO_DATA(error);
        goto fail;
    }
    gwy_debug("column headers %s", line);
    colnames = g_strsplit(line, ",", 0);
    afmwfile->ncolumns = g_strv_length(colnames);
    gwy_debug("ncols %u", afmwfile->ncolumns);
    if (!afmwfile->ncolumns) {
        err_NO_DATA(error);
        g_free(colnames);
        goto fail;
    }
    afmwfile->columns = g_new0(AFMWColumn, afmwfile->ncolumns);
    for (i = 0; i < afmwfile->ncolumns; i++)
        parse_column_header(colnames[i], afmwfile->columns + i);
    /* Individual strings are eaten by parse_column_header(). */
    g_free(colnames);
    data = g_array_new(FALSE, FALSE, sizeof(gdouble));

    while ((line = gwy_str_next_line(&p)) && *line) {
        for (i = 0; i < afmwfile->ncolumns; i++) {
            gdouble v = g_ascii_strtod(line, &sep);

            if (sep == line) {
                g_set_error(error, GWY_MODULE_FILE_ERROR,
                            GWY_MODULE_FILE_ERROR_DATA,
                            _("Data block is truncated"));
                goto fail;
            }
            v *= afmwfile->columns[i].magnitude;
            g_array_append_val(data, v);
            for (line = sep; *line == ',' || g_ascii_isspace(*line); line++)
                ;
        }
    }

    g_free(buf);
    afmwfile->nrows = data->len/afmwfile->ncolumns;
    afmwfile->data = (gdouble*)g_array_free(data, FALSE);
    gwy_debug("nrows %u", afmwfile->nrows);

    return afmwfile;

fail:
    g_free(buf);
    if (data)
        g_array_free(data, TRUE);
    if (afmwfile->columns) {
        for (i = 0; i < afmwfile->ncolumns; i++) {
            g_free(afmwfile->columns[i].name);
            GWY_OBJECT_UNREF(afmwfile->columns[i].unit);
        }
    }
    g_free(afmwfile);

    return NULL;
}

static void
afmw_single_file_free(AFMWSingleFile *afmwfile)
{
    guint i;

    for (i = 0; i < afmwfile->ncolumns; i++) {
        g_free(afmwfile->columns[i].name);
        GWY_OBJECT_UNREF(afmwfile->columns[i].unit);
    }
    g_free(afmwfile->data);
    g_free(afmwfile);
}

static gint
compare_fileinfos(gconstpointer pa, gconstpointer pb)
{
    const AFMWFileInfo *afi = (const AFMWFileInfo*)pa;
    const AFMWFileInfo *bfi = (const AFMWFileInfo*)pb;

    if (afi->datetime.tv_sec < bfi->datetime.tv_sec)
        return -1;
    if (afi->datetime.tv_sec > bfi->datetime.tv_sec)
        return 1;

    if (afi->datetime.tv_usec < bfi->datetime.tv_usec)
        return -1;
    if (afi->datetime.tv_usec > bfi->datetime.tv_usec)
        return 1;

    /* There is no way to include the id here? */

    return 0;
}

static void
make_file_info(GMatchInfo *info, gboolean is_map, AFMWFileInfo *finfo)
{
    gchar buf[20];
    gchar *s;

    s = g_match_info_fetch_named(info, "date");
    g_assert(strlen(s) == 10);
    memcpy(buf, s+6, 4);
    buf[4] = '-';
    memcpy(buf + 5, s+3, 2);
    buf[7] = '-';
    memcpy(buf + 8, s+0, 2);
    buf[10] = 'T';
    g_free(s);

    s = g_match_info_fetch_named(info, "time");
    g_assert(strlen(s) == 8);
    memcpy(buf + 11, s, 8);
    buf[13] = ':';
    buf[16] = ':';
    g_free(s);

    buf[19] = '\0';
    gwy_debug("iso datetime <%s>", buf);

    g_time_val_from_iso8601(buf, &finfo->datetime);

    if (is_map) {
        s = g_match_info_fetch_named(info, "ptid");
        finfo->id = atoi(s);
        g_free(s);
    }
    else
        finfo->id = 0;
}

static gchar**
find_all_file_names(const gchar *filename)
{
    GRegex *name_regex;
    GMatchInfo *info = NULL;
    guint i, len;
    gchar *dirname = NULL, *basename = NULL, *commonname = NULL, *cname;
    gchar **filelist;
    AFMWFileInfo finfo;
    const gchar *fname;
    GArray *files;
    gboolean is_map = TRUE;
    GDir *dir;

    /* It is unclear how to do this.  The files seem to be all called like
     * FD Curve, Single, HH_MM_SS, DD.MM.YYYY.csv
     * FD Curve, Mapping, Point NN, HH_MM_SS, DD.MM.YYYY.csv
     * so it is quite difficult to distinguish between curve sets.  We  try to
     * load all files in a directory, but that is rather agressive. */
    basename = g_path_get_basename(filename);
    len = strlen(basename);

    if (len < 24) {
        g_free(basename);
        return NULL;
    }

    gwy_debug("trying mapping regex");
    name_regex = g_regex_new("^(?<name>.*), "
                             "Point (?<ptid>[0-9]+), "
                             "(?P<time>[0-9]{2}_[0-9]{2}_[0-9]{2}), "
                             "(?P<date>[0-9]{2}\\.[0-9]{2}\\.[0-9]{4})\\."
                             "(csv|CSV)$",
                             G_REGEX_NO_AUTO_CAPTURE
                             | G_REGEX_OPTIMIZE,
                             0, NULL);
    g_return_val_if_fail(name_regex, NULL);
    if (!g_regex_match(name_regex, basename, 0, &info)) {
        gwy_debug("trying single regex");
        g_match_info_free(info);
        info = NULL;
        g_regex_unref(name_regex);
        name_regex = g_regex_new("^(?<name>.*), "
                                 "(?P<time>[0-9]{2}_[0-9]{2}_[0-9]{2}), "
                                 "(?P<date>[0-9]{2}\\.[0-9]{2}\\.[0-9]{4})\\."
                                 "(csv|CSV)$",
                                 G_REGEX_NO_AUTO_CAPTURE
                                 | G_REGEX_OPTIMIZE,
                                 0, NULL);
        g_return_val_if_fail(name_regex, NULL);
        if (!g_regex_match(name_regex, basename, 0, &info)) {
            gwy_debug("cannot match given file name to any regex");
            g_match_info_free(info);
            g_regex_unref(name_regex);
            g_free(basename);
            return NULL;
        }
        is_map = FALSE;
    }
    commonname = g_match_info_fetch_named(info, "name");
    g_match_info_free(info);
    gwy_debug("common name <%s>", commonname);

    dirname = g_path_get_dirname(filename);
    if (!(dir = g_dir_open(dirname, 0, NULL))) {
        /* We will likely fail anyway when this happen, but fail with some
         * cannot-read-given-file message... */
        g_free(dirname);
        g_free(basename);
        g_free(commonname);
        g_regex_unref(name_regex);
        return NULL;
    }

    files = g_array_new(FALSE, FALSE, sizeof(AFMWFileInfo));
    /* Find files with the same filename pattern fooNNN.dat */
    while ((fname = g_dir_read_name(dir))) {
        gwy_debug("found file %s", fname);
        if (!g_regex_match(name_regex, fname, 0, &info)) {
            g_match_info_free(info);
            continue;
        }
        cname = g_match_info_fetch_named(info, "name");
        if (!gwy_strequal(cname, commonname)) {
            g_free(cname);
            g_match_info_free(info);
            continue;
        }
        gwy_debug("seems matching");
        make_file_info(info, is_map, &finfo);
        finfo.filename = g_build_filename(dirname, fname, NULL);
        g_array_append_val(files, finfo);
        g_match_info_free(info);
    }
    g_dir_close(dir);
    g_free(dirname);
    g_free(basename);
    g_free(commonname);
    g_free(name_regex);

    /* This should not normally happen, but something might be changing files
     * on disk... */
    if (!files->len) {
        for (i = 0; i < files->len; i++)
            g_free(g_array_index(files, AFMWFileInfo, i).filename);
        g_array_free(files, TRUE);
        return NULL;
    }

    g_array_sort(files, compare_fileinfos);
    /* XXX: For mapping we can try to cut a single consecutive block of
     * filenames which (1) contains the currectly selected file (2) has
     * increasing sequence of ids.  For single we have no idea what might
     * constitute a spectrum group. */
    filelist = g_new(gchar*, files->len+1);
    for (i = 0; i < files->len; i++)
        filelist[i] = g_array_index(files, AFMWFileInfo, i).filename;
    filelist[files->len] = NULL;
    g_array_free(files, TRUE);

    return filelist;
}

/* vim: set cin et ts=4 sw=4 cino=>1s,e0,n0,f0,{0,}0,^0,\:1s,=0,g1s,h0,t0,+1s,c3,(0,u0 : */