Kaynağa Gözat

Simplyfied FileManager::listFiles()

Jonas Pflanzer 5 yıl önce
ebeveyn
işleme
39510b8d3d
2 değiştirilmiş dosya ile 6 ekleme ve 5 silme
  1. 0 2
      daemon/include/FileManager.h
  2. 6 3
      daemon/src/FileManager.cpp

+ 0 - 2
daemon/include/FileManager.h

@@ -3,8 +3,6 @@
 
 #include <fstream>
 #include <vector>
-#include <boost/filesystem.hpp>
-#include <boost/range/iterator_range.hpp>
 
 /**
  * @class FileManager

+ 6 - 3
daemon/src/FileManager.cpp

@@ -1,5 +1,8 @@
 #include "../include/FileManager.h"
 
+#include <boost/filesystem.hpp>
+#include <boost/range/iterator_range.hpp>
+
 FileManager::FileManager() {}
 
 FileManager::~FileManager() {
@@ -83,9 +86,9 @@ std::vector<char> FileManager::readGet() {
 std::vector<std::string> FileManager::listFiles() {
   std::vector<std::string> res;
   // TODO make path configurable
-  boost::filesystem::path p{"."};
-  for(auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(p), {})) {
-    if(boost::filesystem::is_directory(entry.path()))
+  for (const auto &entry :
+       boost::filesystem::directory_iterator(this->fileDirectory)) {
+    if (boost::filesystem::is_directory(entry.path()))
       continue;
     res.push_back(entry.path().string());
   }