1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
/*
suPHP - (c)2002-2005 Sebastian Marsching <sebastian@marsching.com>
This file is part of suPHP.
suPHP 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; either version 2 of the License, or
(at your option) any later version.
suPHP 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 suPHP; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SUPHP_FILE_H
namespace suPHP {
class File;
enum FileMode {
FILEMODE_USER_READ,
FILEMODE_USER_WRITE,
FILEMODE_USER_EXEC,
FILEMODE_GROUP_READ,
FILEMODE_GROUP_WRITE,
FILEMODE_GROUP_EXEC,
FILEMODE_OTHERS_READ,
FILEMODE_OTHERS_WRITE,
FILEMODE_OTHERS_EXEC
};
};
#define SUPHP_FILE_H
#include <string>
#include <iostream>
#include <fstream>
#include "IOException.hpp"
#include "SystemException.hpp"
#include "SmartPtr.hpp"
#include "UserInfo.hpp"
#include "GroupInfo.hpp"
namespace suPHP {
/**
* Class encapsulating file information and access.
*/
class File {
private:
std::string path;
bool hasPermissionBit(FileMode perm) const throw (SystemException);
public:
/**
* Constructor
*/
File(std::string path);
/**
* Returns path to file
*/
std::string getPath() const;
/**
* Returns input stream to read from file
*/
SmartPtr<std::ifstream> getInputStream() throw (IOException);
/**
* Does file exists?
*/
bool exists() const;
/**
* Returns real path to file (without symlinks in path)
*/
std::string getRealPath() const throw (SystemException);
/**
* Returns File object representing parent directory
*/
File getParentDirectory() const;
/**
* Returns permission bit
*/
bool hasUserReadBit() const throw (SystemException);
/**
* Returns permission bit
*/
bool hasUserWriteBit() const throw (SystemException);
/**
* Returns permission bit
*/
bool hasUserExecuteBit() const throw (SystemException);
/**
* Returns permission bit
*/
bool hasGroupReadBit() const throw (SystemException);
/**
* Returns permission bit
*/
bool hasGroupWriteBit() const throw (SystemException);
/**
* Returns permission bit
*/
bool hasGroupExecuteBit() const throw (SystemException);
/**
* Returns permission bit
*/
bool hasOthersReadBit() const throw (SystemException);
/**
* Returns permission bit
*/
bool hasOthersWriteBit() const throw (SystemException);
/**
* Returns permission bit
*/
bool hasOthersExecuteBit() const throw (SystemException);
/**
* Returns owner (user) of file
*/
UserInfo getUser() const throw (SystemException);
/**
* Returns owning group of file
*/
GroupInfo getGroup() const throw (SystemException);
};
};
#endif // SUPHP_FILE_H
|