From 479ed7ab493c4423a4cc48adbf5ad420224fabb4 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 29 Oct 2019 00:58:27 +0100 Subject: Add search menu tab (currently only manga) --- src/Storage.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Storage.cpp') diff --git a/src/Storage.cpp b/src/Storage.cpp index 1a199d9..ddfdb11 100644 --- a/src/Storage.cpp +++ b/src/Storage.cpp @@ -1,6 +1,7 @@ #include "../include/Storage.hpp" #include "../include/env.hpp" #include +#include #if OS_FAMILY == OS_FAMILY_POSIX #include @@ -88,6 +89,7 @@ namespace QuickMedia { } int file_get_content(const Path &path, std::string &result) { + assert(get_file_type(path) == FileType::REGULAR); FILE *file = fopen(path.data.c_str(), "rb"); if(!file) return -errno; @@ -122,4 +124,11 @@ namespace QuickMedia { return errno; return close(fd); } + + void for_files_in_dir(const Path &path, FileIteratorCallback callback) { + for(auto &p : std::filesystem::directory_iterator(path.data)) { + if(!callback(p.path())) + break; + } + } } \ No newline at end of file -- cgit v1.2.3