Changeset 1186


Ignore:
Timestamp:
Aug 28, 2010, 12:13:37 AM (10 years ago)
Author:
Peter Johansson
Message:

using errno_error. closes #410

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/svndigest.cc

    r1182 r1186  
    228228    std::cout << "Generating output" << std::endl;
    229229  mkdir(tree.name());
    230   chdir(tree.name().c_str());
     230  chdir(tree.name());
    231231  print_css("svndigest.css");
    232232  print_main_page(tree.name(), tree.log(), stats, tree.url());
  • trunk/bin/svndigestParameter.cc

    r1119 r1186  
    9393        std::string base_root = file_name(root());
    9494        std::string path = concatenate_path(target_.value(),base_root);
    95         if (access_rights(target_.value().c_str(), "w")) {
     95        if (access_rights(target_.value(), "w")) {
    9696          std::stringstream ss;
    9797          ss << "svndigest: cannot create directory `" << path
  • trunk/lib/Directory.cc

    r1137 r1186  
    7878        case SVN::uptodate:
    7979          struct stat nodestat;                // C api from sys/stat.h
    80           lstat(fullpath.c_str(),&nodestat);   // C api from sys/stat.h
     80          lstat(fullpath,&nodestat);   // C api from sys/stat.h
    8181          if (S_ISDIR(nodestat.st_mode))       // C api from sys/stat.h
    8282            daughters_.push_back(new Directory(level_+1,fullpath,local_path()));
  • trunk/lib/File.cc

    r1154 r1186  
    225225    stats_.print(os);
    226226    os.close();
    227     rename(tmp_cache_file.c_str(), cache_file.c_str());
     227    rename(tmp_cache_file, cache_file);
    228228    return stats_;
    229229  }
  • trunk/lib/Node.cc

    r1137 r1186  
    6363
    6464    struct stat nodestat;                // C api from sys/stat.h
    65     lstat(path.c_str(),&nodestat);   // C api from sys/stat.h
     65    lstat(path,&nodestat);   // C api from sys/stat.h
    6666    link_ = S_ISLNK(nodestat.st_mode);
    6767  }
  • trunk/lib/rmdirhier.cc

    r1090 r1186  
    7070    struct stat buf;
    7171    // using lstat because links should not be treated as dirs
    72     lstat(dir.c_str(),&buf);
     72    lstat(dir, &buf);
    7373    // check if dir - if not delete the node
    7474    if (!(buf.st_mode & S_IFDIR)) {
  • trunk/lib/utility.cc

    r1132 r1186  
    170170
    171171
     172  void lstat(const std::string path, struct stat* nodestat)
     173  {
     174    int res = ::lstat(path.c_str(), nodestat);
     175    if (res) {
     176      throw yat::utility::errno_error("lstat: ");
     177    }
     178  }
     179
     180
    172181  std::string ltrim(std::string str)
    173182  {
     
    183192    if (code){
    184193      std::stringstream ss;
    185       ss << "mkdir(" << dir << "): failed\n" << strerror(errno);
    186       throw std::runtime_error(ss.str());
     194      ss << "mkdir: `" << dir << "': ";
     195      throw yat::utility::errno_error(ss.str());
    187196    }
    188197  }
     
    294303    if (code){
    295304      std::stringstream ss;
    296       ss << "rename(" << from << ", " << to << "): failed\n" << strerror(errno);
    297       throw std::runtime_error(ss.str());
     305      ss << "rename" << from << " to " << to << ": ";
     306      throw yat::utility::errno_error(ss.str());
    298307    }
    299308  }
  • trunk/lib/utility.h

    r1132 r1186  
    115115  ///
    116116  std::string htrim(std::string str);
     117
     118  /**
     119     same as lstat(2) but throws an errno_error if error is detected
     120   */
     121  void lstat(const std::string path, struct stat*);
    117122
    118123  ///
Note: See TracChangeset for help on using the changeset viewer.