1 /* PSPP - computes sample statistics.
2 Copyright (C) 2006 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 #include "any-writer.h"
26 #include <libpspp/assertion.h>
27 #include <libpspp/message.h>
28 #include "file-handle-def.h"
29 #include "file-name.h"
30 #include "por-file-writer.h"
31 #include "sys-file-writer.h"
32 #include <libpspp/str.h>
33 #include "scratch-writer.h"
37 #define _(msgid) gettext (msgid)
39 /* Creates and returns a writer for HANDLE with the given DICT. */
41 any_writer_open (struct file_handle *handle, struct dictionary *dict)
43 switch (fh_get_referent (handle))
47 struct casewriter *writer;
50 extension = fn_extension (fh_get_file_name (handle));
51 str_lowercase (extension);
53 if (!strcmp (extension, ".por"))
54 writer = pfm_open_writer (handle, dict,
55 pfm_writer_default_options ());
57 writer = sfm_open_writer (handle, dict,
58 sfm_writer_default_options ());
65 msg (ME, _("The inline file is not allowed here."));
69 return scratch_writer_open (handle, dict);