1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2006, 2010, 2011 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU 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, see <http://www.gnu.org/licenses/>. */
19 #include "data/any-writer.h"
26 #include "data/dataset-writer.h"
27 #include "data/file-handle-def.h"
28 #include "data/file-name.h"
29 #include "data/por-file-writer.h"
30 #include "data/sys-file-writer.h"
31 #include "libpspp/assertion.h"
32 #include "libpspp/message.h"
33 #include "libpspp/str.h"
35 #include "gl/xalloc.h"
38 #define _(msgid) gettext (msgid)
40 /* Creates and returns a writer for HANDLE with the given DICT. The caller
41 retains ownership of DICT, which might get modified to assign short names. */
43 any_writer_open (struct file_handle *handle, struct dictionary *dict)
45 switch (fh_get_referent (handle))
49 struct casewriter *writer;
52 extension = fn_extension (handle);
53 str_lowercase (extension);
55 if (!strcmp (extension, ".por"))
56 writer = pfm_open_writer (handle, dict,
57 pfm_writer_default_options ());
59 writer = sfm_open_writer (handle, dict,
60 sfm_writer_default_options ());
67 msg (ME, _("The inline file is not allowed here."));
71 return dataset_writer_open (handle, dict);