355a11314d16d31e243965227820735062b2a680
Stefan Schuermans add copyright & license

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp  1) /**
libpermissioner/src/Config.cpp  2)  * Permissioner: set file ownerships and permissions
libpermissioner/src/Config.cpp  3)  * Copyright 2020: Stefan Schuermans, Aachen, Germany <stefan@schuermans.info>
libpermissioner/src/Config.cpp  4)  * Copyleft: GNU GENERAL PUBLIC LICENSE version 3 (see LICENSE)
libpermissioner/src/Config.cpp  5)  */
libpermissioner/src/Config.cpp  6) 
Stefan Schuermans move most sources into libp...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp  7) #include <permissioner/Config.h>
libpermissioner/src/Config.cpp  8) #include <permissioner/StringUtils.h>
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Config.cpp    9) 
Stefan Schuermans move most sources into libp...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 10) #include <permissioner/Tree.h>
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Config.cpp   11) 
permissionerd/src/Config.cpp   12) #include <boost/filesystem.hpp>
permissionerd/src/Config.cpp   13) #include <fstream>
permissionerd/src/Config.cpp   14) #include <map>
permissionerd/src/Config.cpp   15) #include <sstream>
permissionerd/src/Config.cpp   16) #include <stdexcept>
permissionerd/src/Config.cpp   17) #include <string>
permissionerd/src/Config.cpp   18) 
permissionerd/src/Config.cpp   19) void Config::parseFile(std::string const &configFileName) {
permissionerd/src/Config.cpp   20)   std::ifstream configFile(configFileName, std::ios::in);
permissionerd/src/Config.cpp   21)   if (! configFile.is_open()) {
permissionerd/src/Config.cpp   22)     std::stringstream msg;
permissionerd/src/Config.cpp   23)     msg << "cannot open file \"" << configFileName << "\" for reading";
permissionerd/src/Config.cpp   24)     throw std::runtime_error(msg.str());
permissionerd/src/Config.cpp   25)   }
permissionerd/src/Config.cpp   26) 
permissionerd/src/Config.cpp   27)   for (std::string line; std::getline(configFile, line); ) {
permissionerd/src/Config.cpp   28)     std::string::size_type pos = 0;
permissionerd/src/Config.cpp   29)     std::string typeStr;
permissionerd/src/Config.cpp   30)     try {
permissionerd/src/Config.cpp   31)       StringUtils::getNextField(line, pos, typeStr, "config line type");
permissionerd/src/Config.cpp   32)     } catch (std::exception const &e) {
permissionerd/src/Config.cpp   33)       continue; // empty line -> ignore
permissionerd/src/Config.cpp   34)     }
permissionerd/src/Config.cpp   35)     if (typeStr == "#") {
permissionerd/src/Config.cpp   36)       continue; // comment line -> ignore
permissionerd/src/Config.cpp   37)     }
Stefan Schuermans canonicalize root paths

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 38)     // actual configuration lines
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Config.cpp   39)     if (typeStr == "tree") {
permissionerd/src/Config.cpp   40)       Tree tree;
permissionerd/src/Config.cpp   41)       tree.parseParams(line.substr(pos));
Stefan Schuermans add config getters

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 42)       trees[tree.getRoot()] = tree;
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Config.cpp   43)       continue;
permissionerd/src/Config.cpp   44)     }
permissionerd/src/Config.cpp   45)     // unknown configuration line
permissionerd/src/Config.cpp   46)     std::stringstream msg;
permissionerd/src/Config.cpp   47)     msg << "unknown configuration type \"" << typeStr << "\"";
permissionerd/src/Config.cpp   48)     throw std::runtime_error(msg.str());
permissionerd/src/Config.cpp   49)   }
permissionerd/src/Config.cpp   50) }
Stefan Schuermans add config getters

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 51) 
Stefan Schuermans implement chown/chmod

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 52) TreeMap const & Config::getTrees() const {
Stefan Schuermans add config getters

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 53)   return trees;
libpermissioner/src/Config.cpp 54) }