projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Consolidate quoting style in printed strings.
[pspp]
/
src
/
data
/
any-reader.c
diff --git
a/src/data/any-reader.c
b/src/data/any-reader.c
index 1c1b519b2dce7c289d8cb11d340582cbc199dcf3..807c4fe90e95aab67a2b91bd0226820feecd462a 100644
(file)
--- a/
src/data/any-reader.c
+++ b/
src/data/any-reader.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006
, 2010
Free Software Foundation, Inc.
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
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
@@
-42,30
+42,38
@@
enum detect_result
IO_ERROR /* File couldn't be opened. */
};
IO_ERROR /* File couldn't be opened. */
};
-/* Tries to detect whether HANDLE represents a given type of
- file, by opening the file and passing it to DETECT, and
- returns a detect_result. */
+/* Tries to detect whether FILE is a given type of file, by opening the file
+ and passing it to DETECT, and returns a detect_result. */
static enum detect_result
static enum detect_result
-try_detect (
struct file_handle *handl
e, bool (*detect) (FILE *))
+try_detect (
const char *file_nam
e, bool (*detect) (FILE *))
{
FILE *file;
bool is_type;
{
FILE *file;
bool is_type;
- file = fn_open (f
h_get_file_name (handle)
, "rb");
+ file = fn_open (f
ile_name
, "rb");
if (file == NULL)
{
if (file == NULL)
{
- msg (ME, _("An error occurred while opening
\"%s\"
: %s."),
- f
h_get_file_name (handle)
, strerror (errno));
+ msg (ME, _("An error occurred while opening
`%s'
: %s."),
+ f
ile_name
, strerror (errno));
return IO_ERROR;
}
is_type = detect (file);
return IO_ERROR;
}
is_type = detect (file);
- fn_close (f
h_get_file_name (handle)
, file);
+ fn_close (f
ile_name
, file);
return is_type ? YES : NO;
}
return is_type ? YES : NO;
}
+/* Returns true if any_reader_open() would be able to open FILE as a data
+ file, false otherwise. */
+bool
+any_reader_may_open (const char *file)
+{
+ return (try_detect (file, sfm_detect) == YES
+ || try_detect (file, pfm_detect) == YES);
+}
+
/* Returns a casereader for HANDLE. On success, returns the new
casereader and stores the file's dictionary into *DICT. On
failure, returns a null pointer. */
/* Returns a casereader for HANDLE. On success, returns the new
casereader and stores the file's dictionary into *DICT. On
failure, returns a null pointer. */
@@
-78,19
+86,19
@@
any_reader_open (struct file_handle *handle, struct dictionary **dict)
{
enum detect_result result;
{
enum detect_result result;
- result = try_detect (
handle
, sfm_detect);
+ result = try_detect (
fh_get_file_name (handle)
, sfm_detect);
if (result == IO_ERROR)
return NULL;
else if (result == YES)
return sfm_open_reader (handle, dict, NULL);
if (result == IO_ERROR)
return NULL;
else if (result == YES)
return sfm_open_reader (handle, dict, NULL);
- result = try_detect (
handle
, pfm_detect);
+ result = try_detect (
fh_get_file_name (handle)
, pfm_detect);
if (result == IO_ERROR)
return NULL;
else if (result == YES)
return pfm_open_reader (handle, dict, NULL);
if (result == IO_ERROR)
return NULL;
else if (result == YES)
return pfm_open_reader (handle, dict, NULL);
- msg (SE, _("
\"%s\"
is not a system or portable file."),
+ msg (SE, _("
`%s'
is not a system or portable file."),
fh_get_file_name (handle));
return NULL;
}
fh_get_file_name (handle));
return NULL;
}