1
// ***************************************************************** -*- C++ -*-
3
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
5
* This program is part of the Exiv2 distribution.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
25
History: 08-Dec-03, ahu: created
26
02-Apr-05, ahu: moved to Exiv2 namespace
28
// *****************************************************************************
30
EXIV2_RCSID("@(#) $Id: futils.cpp 560 2005-04-17 11:51:32Z ahuggel $");
32
// *****************************************************************************
33
// included header files
35
# include "exv_msvc.h"
37
# include "exv_conf.h"
42
// + standard includes
43
#include <sys/types.h>
46
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
48
#ifdef EXV_HAVE_UNISTD_H
49
# include <unistd.h> // for stat()
58
// *****************************************************************************
61
bool fileExists(const std::string& path, bool ct)
64
int ret = stat(path.c_str(), &buf);
65
if (0 != ret) return false;
66
if (ct && !S_ISREG(buf.st_mode)) return false;
70
std::string strError()
73
std::ostringstream os;
74
os << strerror(error) << " (" << error << ")";