Skip to content

Commit

Permalink
Remove boost filesystem as it's a library and fix bug in logic
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSimpson committed Aug 16, 2017
1 parent ac98e28 commit f6e0a7c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/dl-intercept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <iostream>
#include <fstream>
#include "boost/algorithm/string.hpp"
#include "boost/filesystem.hpp"

static std::unordered_map<std::string, std::string> substitutions;

Expand Down Expand Up @@ -52,10 +51,15 @@ static void process_environment_variables() {
std::vector<std::string> substitution_pairs;

// Extract substitution pairs into vector
if(boost::filesystem::is_regular_file(dl_substitutions)) {
if(dl_substitutions.find(':') == std::string::npos) { // If a filename was provided or malformed pair
// Read substitution pairs from file line by line
std::ifstream substitutions_file;
substitutions_file.open(dl_substitutions, std::ifstream::in);
if(substitutions_file.bad()) {
std::cout<<"ERROR: Failure to open substitutions file " << dl_substitutions << std::endl;
exit(1);
}

std::string line;

while(getline(substitutions_file, line)) {
Expand All @@ -64,7 +68,7 @@ static void process_environment_variables() {

// Ignore line starting with '#' to allow comments
// And only add strings which contain a ":"
if(line.at(0) == '#' || line.find(':') != std::string::npos) {
if(line.at(0) == '#' || line.find(':') == std::string::npos) {
continue;
}
else {
Expand Down

0 comments on commit f6e0a7c

Please sign in to comment.