Changeset 151 for trunk/lib/utility.cc
- Timestamp:
- Aug 13, 2006, 10:30:02 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/utility.cc
r149 r151 27 27 #include <iostream> // remove this when 'blame' is removed 28 28 #include <sstream> 29 #include <stdexcept> 29 30 #include <string> 30 31 #include <sys/param.h> … … 33 34 namespace theplu{ 34 35 namespace svndigest{ 36 37 int access_rights(const std::string& path, const std::string& bits) 38 { 39 if (int value=access(path.c_str(),F_OK)) { 40 throw std::runtime_error(std::string("access_rights: ") + path + 41 "' does not exist."); 42 } 43 int mode=0; 44 for (u_int i=0; i<bits.length(); i++) 45 switch (bits[i]) { 46 case 'r': 47 mode|=R_OK; 48 break; 49 case 'w': 50 mode|=W_OK; 51 break; 52 case 'x': 53 mode|=X_OK; 54 break; 55 } 56 return access(path.c_str(),mode); 57 } 58 35 59 36 60 std::string file_name(const std::string& full_path) … … 41 65 return name; 42 66 } 67 43 68 44 69 void print_css(std::ostream& s) … … 130 155 { 131 156 char buffer[MAXPATHLEN]; 132 getcwd(buffer, MAXPATHLEN); 157 if (!getcwd(buffer, MAXPATHLEN)) 158 throw std::runtime_error("Failed to get current working directory"); 133 159 return std::string(buffer); 134 160 } 135 161 136 137 138 162 }} // end of namespace svndigest and namespace theplu
Note: See TracChangeset
for help on using the changeset viewer.