diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-10-29 00:58:27 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2019-10-29 00:59:49 +0100 |
commit | 479ed7ab493c4423a4cc48adbf5ad420224fabb4 (patch) | |
tree | 4bcb1b33b6b99bb02f3ef0bf0cc7f2536edc51c0 /src/Storage.cpp | |
parent | be7a58b8e37e70bae5c6699ca9b7a0fec1fd72f9 (diff) |
Add search menu tab (currently only manga)
Diffstat (limited to 'src/Storage.cpp')
-rw-r--r-- | src/Storage.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
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 <stdio.h> +#include <assert.h> #if OS_FAMILY == OS_FAMILY_POSIX #include <pwd.h> @@ -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 |