Ignore:
Timestamp:
Dec 21, 2006, 9:10:30 AM (15 years ago)
Author:
Jari Häkkinen
Message:

Fixes #1 and #80. Interface changed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/FileUtil.cc

    r710 r711  
    4040
    4141  FileUtil::FileUtil(const std::string& path)
    42     : no_file_(false), path_(path)
     42    : path_(path)
    4343  {
    44     if ( stat(path_.c_str(),&stat_) && !(no_file_=(errno==ENOENT)) )
    45         throw IO_error(std::string("stat(2) call failed with errno: "+errno));
    4644  }
    4745
    4846
    49   int FileUtil::access_rights(const std::string& path,
    50                               const std::string& bits) const
     47  int FileUtil::permissions(const std::string& bits) const
    5148  {
    5249    std::string tryme=path_;
    53     if (no_file_) {
     50    if (!exists()) {
    5451      std::string::size_type pos=path_.find_last_of('/');
    5552      tryme = ( (pos!=std::string::npos) ? path_.substr(0,pos) : "." );
     
    7471
    7572
    76   bool FileUtil::file_exists(const std::string& file) const
     73  bool FileUtil::exists(void) const
    7774  {
    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
    7979  }
    8080
Note: See TracChangeset for help on using the changeset viewer.