aboutsummaryrefslogtreecommitdiff
path: root/include/FileUtil.hpp
blob: 8407a36b997db5e04a2c2a06b52649ed54ddfd00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef SIBS_FILEUTIL_HPP
#define SIBS_FILEUTIL_HPP

#include "../external/tinydir.h"
#include "Result.hpp"
#include "StringView.hpp"
#include <functional>

namespace sibs
{
    using FileWalkCallbackFunc = std::function<void(tinydir_file*)>;

    enum class FileType
    {
        FILE_NOT_FOUND,
        REGULAR,
        DIRECTORY
    };

    FileType getFileType(const char *path);
    void walkDir(const char *directory, FileWalkCallbackFunc callbackFunc);
    void walkDirFiles(const char *directory, FileWalkCallbackFunc callbackFunc);
    void walkDirFilesRecursive(const char *directory, FileWalkCallbackFunc callbackFunc);
    Result<StringView> getFileContent(const char *filepath);
    bool fileOverwrite(const char *filepath, StringView data);
    const char* getHomeDir();
    Result<std::string> getCwd();
}

#endif //SIBS_FILEUTIL_HPP