1 /* vi: set sw=4 ts=4: */
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
15 void bb_xprint_and_close_file(FILE *file)
18 /* Note: Do not use STDOUT_FILENO here, as this is a lib routine
19 * and the calling code may have reassigned stdout. */
20 if (bb_copyfd_eof(fileno(file), STDOUT_FILENO) == -1) {
21 /* bb_copyfd outputs any needed messages, so just die. */
22 exit(bb_default_error_retval);
24 /* Note: Since we're reading, don't bother checking the return value
25 * of fclose(). The only possible failure is EINTR which
26 * should already have been taken care of. */
32 * -1 if 'filename' does not exist or is a directory
33 * exits with default error code if an error occurs
36 int bb_xprint_file_by_name(const char *filename)
41 /* This check shouldn't be necessary for linux, but is left
42 * here disabled just in case. */
45 if(is_directory(filename, TRUE, &statBuf)) {
46 bb_error_msg("%s: Is directory", filename);
49 if ((f = bb_wfopen(filename, "r")) != NULL) {
50 bb_xprint_and_close_file(f);