2 suPHP - (c)2002-2008 Sebastian Marsching <sebastian@marsching.com>
4 This file is part of suPHP.
6 suPHP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 suPHP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with suPHP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "API_Helper.hpp"
25 using namespace suPHP
;
27 bool suPHP::File::hasPermissionBit(FileMode perm
) const throw (SystemException
) {
28 return API_Helper::getSystemAPI().File_hasPermissionBit(*this, perm
);
31 suPHP::File::File(std::string path
) {
35 std::string
suPHP::File::getPath() const{
39 SmartPtr
<std::ifstream
> suPHP::File::getInputStream() const throw (IOException
) {
40 std::ifstream
* infile
= new std::ifstream();
41 infile
->open(this->path
.c_str());
42 if (infile
->bad() || infile
->fail()) {
43 throw IOException("Could not open file " +
44 this->path
+ " for reading", __FILE__
, __LINE__
);
46 return SmartPtr
<std::ifstream
>(infile
);
49 bool suPHP::File::exists() const {
50 return API_Helper::getSystemAPI().File_exists(*this);
53 std::string
suPHP::File::getRealPath() const throw (SystemException
) {
54 return API_Helper::getSystemAPI().File_getRealPath(*this);
57 File
suPHP::File::getParentDirectory() const {
58 std::string path
= this->getPath();
59 path
= path
.substr(0, path
.rfind('/'));
60 if (path
.length() == 0) {
66 bool suPHP::File::hasUserReadBit() const throw (SystemException
) {
67 return this->hasPermissionBit(FILEMODE_USER_READ
);
70 bool suPHP::File::hasUserWriteBit() const throw (SystemException
) {
71 return this->hasPermissionBit(FILEMODE_USER_WRITE
);
74 bool suPHP::File::hasUserExecuteBit() const throw (SystemException
) {
75 return this->hasPermissionBit(FILEMODE_USER_EXEC
);
78 bool suPHP::File::hasGroupReadBit() const throw (SystemException
) {
79 return this->hasPermissionBit(FILEMODE_GROUP_READ
);
82 bool suPHP::File::hasGroupWriteBit() const throw (SystemException
) {
83 return this->hasPermissionBit(FILEMODE_GROUP_WRITE
);
86 bool suPHP::File::hasGroupExecuteBit() const throw (SystemException
) {
87 return this->hasPermissionBit(FILEMODE_GROUP_EXEC
);
90 bool suPHP::File::hasOthersReadBit() const throw (SystemException
) {
91 return this->hasPermissionBit(FILEMODE_OTHERS_READ
);
94 bool suPHP::File::hasOthersWriteBit() const throw (SystemException
) {
95 return this->hasPermissionBit(FILEMODE_OTHERS_WRITE
);
98 bool suPHP::File::hasOthersExecuteBit() const throw (SystemException
) {
99 return this->hasPermissionBit(FILEMODE_OTHERS_EXEC
);
103 UserInfo
suPHP::File::getUser() const throw (SystemException
) {
104 return API_Helper::getSystemAPI().File_getUser(*this);
107 GroupInfo
suPHP::File::getGroup() const throw (SystemException
) {
108 return API_Helper::getSystemAPI().File_getGroup(*this);
112 bool suPHP::File::isSymlink() const throw (SystemException
) {
113 return API_Helper::getSystemAPI().File_isSymlink(*this);