aboutsummaryrefslogtreecommitdiff
path: root/include/dchat/FileUtil.hpp
blob: 6a7ff001091d739894c35086d6af264b1a7490d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#pragma once

#include "StringView.hpp"
#include <boost/filesystem/path.hpp>
#include <stdexcept>

namespace dchat
{
    class FileException : public std::runtime_error
    {
    public:
        FileException(const std::string &errMsg) : std::runtime_error(errMsg) {}
    };
    
    // Throws FileException on error.
    // Returned value is allocated with `new[]` and should be `delete`[]d by caller.
    StringView getFileContent(const boost::filesystem::path &filepath);
    
    // Throws FileException on error
    void fileReplace(const boost::filesystem::path &filepath, const StringView data);
}