aboutsummaryrefslogtreecommitdiff
path: root/include/odhtdb/FileUtils.hpp
blob: 155f53a6aad7e1a61fbb6714a2f36f2c9ab4db69 (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
#pragma once

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

namespace odhtdb
{
    class FileException : public std::runtime_error
    {
    public:
        FileException(const std::string &errMsg) : std::runtime_error(errMsg) {}
    };
    
    // Throws FileException on error
    OwnedByteArray fileGetContent(const boost::filesystem::path &filepath);
    
    // Creates file if it doesn't exist.
    // Throws FileException on error
    void fileAppend(const boost::filesystem::path &filepath, const DataView &data);
    
    // Creates a file if it doesn'te xist.
    // Throws FileException on error.
    void fileOverwrite(const boost::filesystem::path &filepath, const DataView &data);
}