summaryrefslogtreecommitdiff
path: root/util/fluxbox-update_configs.cc
diff options
context:
space:
mode:
Diffstat (limited to 'util/fluxbox-update_configs.cc')
-rw-r--r--util/fluxbox-update_configs.cc17
1 files changed, 5 insertions, 12 deletions
diff --git a/util/fluxbox-update_configs.cc b/util/fluxbox-update_configs.cc
index 96382da..85bbbfe 100644
--- a/util/fluxbox-update_configs.cc
+++ b/util/fluxbox-update_configs.cc
@@ -22,8 +22,9 @@
22#include "../src/FbTk/I18n.hh" 22#include "../src/FbTk/I18n.hh"
23#include "../src/FbTk/Resource.hh" 23#include "../src/FbTk/Resource.hh"
24#include "../src/FbTk/StringUtil.hh" 24#include "../src/FbTk/StringUtil.hh"
25#include "../src/FbTk/FileUtil.hh"
25 26
26#include "../src/defaults.hh" 27#include "defaults.hh"
27 28
28#ifdef HAVE_CONFIG_H 29#ifdef HAVE_CONFIG_H
29#include "config.h" 30#include "config.h"
@@ -463,7 +464,7 @@ set<string> modified_files;
463// we may want to put a size limit on this cache, so it doesn't grow too big 464// we may want to put a size limit on this cache, so it doesn't grow too big
464map<string,string> file_cache; 465map<string,string> file_cache;
465 466
466}; 467}
467 468
468// returns the contents of the file given, either from the cache or by reading 469// returns the contents of the file given, either from the cache or by reading
469// the file from disk 470// the file from disk
@@ -473,11 +474,9 @@ string read_file(const string& filename) {
473 if (it != file_cache.end()) 474 if (it != file_cache.end())
474 return it->second; 475 return it->second;
475 476
476 struct stat s; 477 if (!FbTk::FileUtil::isRegularFile(filename.c_str())) {
477 stat(filename.c_str(), &s);
478
479 if (! (s.st_mode & S_IFREG))
480 return ""; 478 return "";
479 }
481 480
482 // nope, we'll have to read the file 481 // nope, we'll have to read the file
483 ifstream infile(filename.c_str()); 482 ifstream infile(filename.c_str());
@@ -489,12 +488,6 @@ string read_file(const string& filename) {
489 string linebuffer; 488 string linebuffer;
490 while (!infile.eof()) { 489 while (!infile.eof()) {
491 getline(infile, linebuffer); 490 getline(infile, linebuffer);
492
493 // check if we read something at all. if its 0, its a strange file
494 // (eg a directory) or we are at the end
495 if (infile.gcount() == 0) {
496 break;
497 }
498 whole_file += linebuffer + "\n"; 491 whole_file += linebuffer + "\n";
499 } 492 }
500 infile.close(); 493 infile.close();