Changeset 711 for trunk/yat/utility/FileUtil.cc
- Timestamp:
- Dec 21, 2006, 9:10:30 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/FileUtil.cc
r710 r711 40 40 41 41 FileUtil::FileUtil(const std::string& path) 42 : no_file_(false),path_(path)42 : path_(path) 43 43 { 44 if ( stat(path_.c_str(),&stat_) && !(no_file_=(errno==ENOENT)) )45 throw IO_error(std::string("stat(2) call failed with errno: "+errno));46 44 } 47 45 48 46 49 int FileUtil::access_rights(const std::string& path, 50 const std::string& bits) const 47 int FileUtil::permissions(const std::string& bits) const 51 48 { 52 49 std::string tryme=path_; 53 if ( no_file_) {50 if (!exists()) { 54 51 std::string::size_type pos=path_.find_last_of('/'); 55 52 tryme = ( (pos!=std::string::npos) ? path_.substr(0,pos) : "." ); … … 74 71 75 72 76 bool FileUtil:: file_exists(const std::string& file) const73 bool FileUtil::exists(void) const 77 74 { 78 return !no_file_; 75 struct stat statt; 76 if ( stat(path_.c_str(),&statt) && (errno!=ENOENT) ) 77 throw IO_error(std::string("stat(2) call failed with errno: "+errno)); 78 return !errno; // 0 if file exists, non-zero if file does not exist 79 79 } 80 80
Note: See TracChangeset
for help on using the changeset viewer.