1cbbe96195b6154b1957a73808eced432e994792
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 add nice and I/O idle config

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 39)     if (typeStr == "nice") {
libpermissioner/src/Config.cpp 40)       nice.parseParams(line.substr(pos));
libpermissioner/src/Config.cpp 41)       continue;
libpermissioner/src/Config.cpp 42)     }
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

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

Stefan Schuermans authored 4 years ago

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

Stefan Schuermans authored 4 years ago

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

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 55) 
Stefan Schuermans add nice and I/O idle config

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 56) Nice const & Config::getNice() const {
libpermissioner/src/Config.cpp 57)   return nice;
libpermissioner/src/Config.cpp 58) }
libpermissioner/src/Config.cpp 59) 
Stefan Schuermans implement chown/chmod

Stefan Schuermans authored 4 years ago

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

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 61)   return trees;
libpermissioner/src/Config.cpp 62) }