~ubuntu-branches/ubuntu/quantal/poco/quantal

« back to all changes in this revision

Viewing changes to Foundation/src/File_UNIX.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Burghardt
  • Date: 2008-11-15 11:39:15 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081115113915-7kauhm2c3m2i7oid
Tags: 1.3.3p1-2
* Fixed FTBFS with GCC 4.4 due to missing #include (Closes: #505619)
* Renamed 20_gcc43-missing-include.dpatch to 20_gcc44-missing-include.dpatch
* Downgraded dependencies on -dbg packages (Closes: #504342)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
2
// File_UNIX.cpp
3
3
//
4
 
// $Id: //poco/1.3/Foundation/src/File_UNIX.cpp#6 $
 
4
// $Id: //poco/1.3/Foundation/src/File_UNIX.cpp#12 $
5
5
//
6
6
// Library: Foundation
7
7
// Package: Filesystem
45
45
#include <unistd.h>
46
46
#include <stdio.h>
47
47
#include <utime.h>
 
48
#include <cstring>
48
49
 
49
50
 
50
51
namespace Poco {
99
100
        struct stat st;
100
101
        if (stat(_path.c_str(), &st) == 0)
101
102
        {
102
 
                if (st.st_uid == geteuid())
 
103
                if (geteuid() == 0)
 
104
                        return true;
 
105
                else if (st.st_uid == geteuid())
103
106
                        return (st.st_mode & S_IRUSR) != 0;
104
107
                else if (st.st_gid == getegid())
105
108
                        return (st.st_mode & S_IRGRP) != 0;
118
121
        struct stat st;
119
122
        if (stat(_path.c_str(), &st) == 0)
120
123
        {
121
 
                if (st.st_uid == geteuid())
 
124
                if (geteuid() == 0)
 
125
                        return true;
 
126
                else if (st.st_uid == geteuid())
122
127
                        return (st.st_mode & S_IWUSR) != 0;
123
128
                else if (st.st_gid == getegid())
124
129
                        return (st.st_mode & S_IWGRP) != 0;
137
142
        struct stat st;
138
143
        if (stat(_path.c_str(), &st) == 0)
139
144
        {
140
 
                if (st.st_uid == geteuid())
 
145
                if (st.st_uid == geteuid() || geteuid() == 0)
141
146
                        return (st.st_mode & S_IXUSR) != 0;
142
147
                else if (st.st_gid == getegid())
143
148
                        return (st.st_mode & S_IXGRP) != 0;
202
207
{
203
208
        poco_assert (!_path.empty());
204
209
 
205
 
        struct stat st;
206
 
        if (stat(_path.c_str(), &st) == 0)
207
 
                return Timestamp::fromEpochTime(st.st_mtime);
 
210
#if defined(__APPLE__) && defined(st_birthtime) // st_birthtime is available only on 10.5
 
211
        struct stat64 st;
 
212
        if (stat64(_path.c_str(), &st) == 0)
 
213
                return Timestamp::fromEpochTime(st.st_birthtime);
 
214
#elif defined(__FreeBSD__)
 
215
        struct stat st;
 
216
        if (stat(_path.c_str(), &st) == 0)
 
217
                return Timestamp::fromEpochTime(st.st_birthtime);
 
218
#else
 
219
        struct stat st;
 
220
        if (stat(_path.c_str(), &st) == 0)
 
221
                return Timestamp::fromEpochTime(st.st_ctime);
 
222
#endif 
208
223
        else
209
224
                handleLastErrorImpl(_path);
210
225
        return 0;