From 71a0acd28eb1a6ee6880e6f2a9f98f328e52521d Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Thu, 19 Aug 2004 13:56:47 +0000 Subject: [PATCH] initial checkin git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1654 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- util-vserver/lib/isfile.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 util-vserver/lib/isfile.c diff --git a/util-vserver/lib/isfile.c b/util-vserver/lib/isfile.c new file mode 100644 index 0000000..2309f50 --- /dev/null +++ b/util-vserver/lib/isfile.c @@ -0,0 +1,37 @@ +// $Id$ --*- c -*-- + +// Copyright (C) 2004 Enrico Scholz +// +// 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 +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "internal.h" + +#include +#include +#include + +bool +utilvserver_isFile(char const *path, bool follow_link) +{ + struct stat st; + if ( ( follow_link && stat(path, &st)==-1) || + (!follow_link && lstat(path, &st)==-1) ) return false; + + return S_ISREG(st.st_mode); +} -- 1.8.1.5