2001-03-16 22:47:14 +00:00
|
|
|
/* vi: set sw=4 ts=4: */
|
|
|
|
/*
|
|
|
|
* Utility routines.
|
|
|
|
*
|
2004-03-15 08:29:22 +00:00
|
|
|
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
2001-03-16 22:47:14 +00:00
|
|
|
*
|
2006-05-19 19:29:19 +00:00
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
2001-03-16 22:47:14 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libbb.h"
|
|
|
|
|
2008-06-27 02:52:20 +00:00
|
|
|
FILE* FAST_FUNC fopen_or_warn(const char *path, const char *mode)
|
2001-03-16 22:47:14 +00:00
|
|
|
{
|
2006-10-26 23:25:17 +00:00
|
|
|
FILE *fp = fopen(path, mode);
|
|
|
|
if (!fp) {
|
2007-10-01 11:58:38 +00:00
|
|
|
bb_simple_perror_msg(path);
|
2001-03-16 22:47:14 +00:00
|
|
|
errno = 0;
|
|
|
|
}
|
|
|
|
return fp;
|
|
|
|
}
|
2008-07-21 23:05:26 +00:00
|
|
|
|
|
|
|
FILE* FAST_FUNC fopen_for_read(const char *path)
|
|
|
|
{
|
|
|
|
return fopen(path, "r");
|
|
|
|
}
|
|
|
|
|
|
|
|
FILE* FAST_FUNC xfopen_for_read(const char *path)
|
|
|
|
{
|
|
|
|
return xfopen(path, "r");
|
|
|
|
}
|
|
|
|
|
|
|
|
FILE* FAST_FUNC fopen_for_write(const char *path)
|
|
|
|
{
|
|
|
|
return fopen(path, "w");
|
|
|
|
}
|
|
|
|
|
|
|
|
FILE* FAST_FUNC xfopen_for_write(const char *path)
|
|
|
|
{
|
|
|
|
return xfopen(path, "w");
|
|
|
|
}
|