|
@@ -82,13 +82,23 @@ std::vector<char> FileManager::readGet() {
|
|
|
|
|
|
std::vector<std::string> FileManager::listFiles() {
|
|
|
std::vector<std::string> res;
|
|
|
+ // TODO make path configurable
|
|
|
boost::filesystem::path p{"."};
|
|
|
- boost::filesystem::file_status s = status(p);
|
|
|
- if(!is_directory(s)) {
|
|
|
- return res;
|
|
|
- }
|
|
|
for(auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(p), {})) {
|
|
|
+ if(boost::filesystem::is_directory(entry.path()))
|
|
|
+ continue;
|
|
|
res.push_back(entry.path().string());
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+int FileManager::getChunksFromFile(const std::string &filename) {
|
|
|
+ boost::filesystem::path p{filename};
|
|
|
+ boost::filesystem::file_status s = status(p);
|
|
|
+ if(is_directory(s)) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ uintmax_t size = boost::filesystem::file_size(filename);
|
|
|
+ int chunks = size / max_data_length + (size % max_data_length == 0 ? 0 : 1);
|
|
|
+ return chunks;
|
|
|
+}
|