|
@@ -94,31 +94,23 @@ std::vector<char> FileManager::readGet() {
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
-std::vector<std::string> FileManager::listFiles() {
|
|
|
- std::vector<std::string> res;
|
|
|
- for (const auto &entry :
|
|
|
- boost::filesystem::directory_iterator(this->fileDirectory)) {
|
|
|
- if (boost::filesystem::is_directory(entry.path()))
|
|
|
- continue;
|
|
|
- res.push_back(entry.path().filename().string());
|
|
|
- }
|
|
|
- return res;
|
|
|
-}
|
|
|
-
|
|
|
int FileManager::openList() {
|
|
|
- std::vector<std::string> fullList = listFiles();
|
|
|
-
|
|
|
- if (fullList.size() == 0) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
// add empty chunk vector
|
|
|
this->list.push_back(std::vector<std::string>());
|
|
|
|
|
|
int cursize = 0;
|
|
|
- for (const std::string &s : fullList) {
|
|
|
+
|
|
|
+ for (const auto &entry :
|
|
|
+ boost::filesystem::directory_iterator(this->fileDirectory)) {
|
|
|
+ // getting filename from
|
|
|
+ if (boost::filesystem::is_directory(entry.path()))
|
|
|
+ continue;
|
|
|
+ const std::string s = entry.path().filename().string();
|
|
|
+
|
|
|
+ // check if the size is too big
|
|
|
if (s.length() > max_data_length)
|
|
|
return -1;
|
|
|
+
|
|
|
cursize += s.length() + 3;
|
|
|
if (cursize > max_data_length) {
|
|
|
this->list.push_back(std::vector<std::string>());
|
|
@@ -129,6 +121,11 @@ int FileManager::openList() {
|
|
|
this->list.back().push_back(s);
|
|
|
}
|
|
|
|
|
|
+ // empty list if no file was read
|
|
|
+ if (this->list.size() == 1 && this->list.back().size() == 0) {
|
|
|
+ this->list.clear();
|
|
|
+ }
|
|
|
+
|
|
|
return this->list.size();
|
|
|
}
|
|
|
|