~noskcaj/ubuntu/trusty/libextractor/merge

« back to all changes in this revision

Viewing changes to src/plugins/exiv2/futils.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-11-17 20:27:32 UTC
  • mfrom: (1.10.4 upstream) (5.2.5 sid)
  • Revision ID: james.westby@ubuntu.com-20091117202732-ipm2h3gks5bdw2vx
Tags: 0.5.23+dfsg-3
* Building against libltdl7.
* Updating to standards version 3.8.3.
* Adding maintainer homepage field to control.
* Marking maintainer homepage field to be also included in binary
  packages and changelog.
* Adding README.source.
* Simplifying autotools handling in rules.
* Updating README.source.
* Moving maintainer homepage field from control to copyright.
* Dropping la files.
* Simplyfing debhelper install files.
* Bumping versioned build-depends on debhelper.
* Adding depends to dpkg install info.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ***************************************************************** -*- C++ -*-
2
 
/*
3
 
 * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
4
 
 *
5
 
 * This program is part of the Exiv2 distribution.
6
 
 *
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.
11
 
 *
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.
16
 
 *
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.
20
 
 */
21
 
/*
22
 
  File:      utils.cpp
23
 
  Version:   $Rev: 560 $
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
27
 
 */
28
 
// *****************************************************************************
29
 
#include "rcsid.hpp"
30
 
EXIV2_RCSID("@(#) $Id: futils.cpp 560 2005-04-17 11:51:32Z ahuggel $");
31
 
 
32
 
// *****************************************************************************
33
 
// included header files
34
 
#ifdef _MSC_VER
35
 
# include "exv_msvc.h"
36
 
#else
37
 
# include "exv_conf.h"
38
 
#endif
39
 
 
40
 
#include "futils.hpp"
41
 
 
42
 
// + standard includes
43
 
#include <sys/types.h>
44
 
#include <sys/stat.h>
45
 
#ifdef _MSC_VER
46
 
# define S_ISREG(m)      (((m) & S_IFMT) == S_IFREG)
47
 
#endif
48
 
#ifdef EXV_HAVE_UNISTD_H
49
 
# include <unistd.h>                     // for stat()
50
 
#endif
51
 
 
52
 
#include <cerrno>
53
 
#include <cstring>
54
 
#include <sstream>
55
 
 
56
 
namespace Exiv2 {
57
 
 
58
 
// *****************************************************************************
59
 
// free functions
60
 
 
61
 
    bool fileExists(const std::string& path, bool ct)
62
 
    {
63
 
        struct stat buf;
64
 
        int ret = stat(path.c_str(), &buf);
65
 
        if (0 != ret)                    return false;
66
 
        if (ct && !S_ISREG(buf.st_mode)) return false;
67
 
        return true;
68
 
    } // fileExists
69
 
 
70
 
    std::string strError()
71
 
    {
72
 
        int error = errno;
73
 
        std::ostringstream os;
74
 
        os << strerror(error) << " (" << error << ")";
75
 
        return os.str();
76
 
    } // strError
77
 
 
78
 
}                                       // namespace Exiv2