Changeset 632 for trunk/bin


Ignore:
Timestamp:
Apr 29, 2008, 12:37:07 AM (15 years ago)
Author:
Peter Johansson
Message:

working on #317

Location:
trunk/bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/Parameter.cc

    r631 r632  
    4444    : config_file_(""), copyright_(false), force_(false),
    4545      generate_config_(false), ignore_cache_(false), report_(true),
    46       revisions_(false), root_("."), targetdir_("."), verbose_(false)
     46      revisions_(false), root_("."), root_node_("."), targetdir_("."),
     47      verbose_(false)
    4748  {
    4849    for (int i=1; i<argc; ++i) {
     
    138139    string workdir(pwd()); // remember current working directory (cwd).
    139140
    140     bool root_ok = ( node_exist(root_.value()) &&
    141                      !access_rights(root_.value(), "r") );
    142    
    143     if (root_ok) {
    144       // Check that root_ is a directory
    145       struct stat nodestat;
    146       stat(root_.value().c_str(), &nodestat);
    147       if (!S_ISDIR(nodestat.st_mode))
    148         throw runtime_error(string("svndigest: accessing `") + root_.value() +
    149                             "': Not a directory.");
     141    if (!node_exist(root_.value()))
     142      throw runtime_error(string("svndigest: cannot stat `" + root_.value() +
     143                                 "': no such file or directory"));
     144
     145    if (access_rights(root_.value(), "r"))
     146      throw runtime_error(string("svndigest: cannot open `" + root_.value() +
     147                                 "' for reading: Permission denied"));
     148
     149    // Check whether root is directory or file
     150    struct stat nodestat;
     151    stat(root_.value().c_str(), &nodestat);
     152    if (S_ISDIR(nodestat.st_mode)) {
     153      chdir(root_.value().c_str());
     154      root_node_.value() = root_.value() = pwd();
    150155    }
    151 
    152     // Checking that root_ exists and retrieve the absolute path to root_
    153     if (!root_ok || chdir(root_.value().c_str()))
    154       throw runtime_error(string("svndigest: Root directory (") + root_.value() +
    155                           ") access failed.");
    156     root_.value() = pwd();
    157 
    158      
     156    else {
     157      std::string fname = file_name(root_.value());
     158      root_.value() = directory_name(root_.value());
     159      chdir(root_.value().c_str());
     160      root_.value() = pwd();
     161      root_node_.value() = root_.value() + "/" + fname;
     162    }
    159163
    160164    // need to get back to cwd if relative paths are used.
  • trunk/bin/Parameter.h

    r626 r632  
    4848    /// @return absolute path to root directory
    4949    inline const std::string& root(void) const { return root_.value(); }
     50    /// @return absolute path to root node
     51    inline const std::string& root_node(void) const {return root_node_.value();}
    5052    /// @return absolute path to target directory
    5153    inline const std::string& targetdir(void) const
     
    6769    Option<bool> revisions_;
    6870    Option<std::string> root_;
     71    Option<std::string> root_node_;
    6972    Option<std::string> targetdir_;
    7073    Option<bool> verbose_;
Note: See TracChangeset for help on using the changeset viewer.