Ignore:
Timestamp:
Oct 13, 2010, 6:10:52 AM (11 years ago)
Author:
Peter Johansson
Message:

closes #480. Quote files with 'file' (same style as subversion). Add a test to check output of some failures and use variable GREP rather than hardcoding grep.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/Parameter.cc

    r1119 r1220  
    9797      check_existence(root_.value());
    9898      check_readable(root_.value());
     99      check_is_dir(root_.value());
    99100      chdir(root_.value());
    100101      root_.value(pwd());
     
    116117      if (S_ISDIR(nodestat.st_mode)) {
    117118        std::stringstream ss;
    118         ss << cmd_.program_name() << ": `" << config_file_.value()
     119        ss << cmd_.program_name() << ": '" << config_file_.value()
    119120           << "' is a directory";
    120121        throw yat::utility::cmd_error(ss.str());
     
    130131      return;
    131132    std::stringstream ss;
    132     ss << cmd_.program_name() << ": cannot stat `" << path << "': "
     133    ss << cmd_.program_name() << ": cannot stat '" << path << "': "
    133134       << strerror(errno);
    134135    throw yat::utility::cmd_error(ss.str());
     
    136137
    137138 
     139  void Parameter::check_is_dir(std::string path) const
     140  {
     141    if (node_exist(path)) {
     142      struct stat buf;
     143      stat(path.c_str(), &buf);
     144      if (S_ISDIR(buf.st_mode))
     145        return;
     146    }
     147    std::stringstream ss;
     148    ss << cmd_.program_name() << ": '" << path << "': "
     149       << strerror(errno);
     150    throw yat::utility::cmd_error(ss.str());
     151  }
     152
     153 
    138154  void Parameter::check_readable(std::string path) const
    139155  {
     
    141157      return;
    142158    std::stringstream ss;
    143     ss << cmd_.program_name() << ": cannot open `" << path << "': "
     159    ss << cmd_.program_name() << ": cannot open '" << path << "': "
    144160       << strerror(errno);
    145161    throw yat::utility::cmd_error(ss.str());
Note: See TracChangeset for help on using the changeset viewer.