aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-dataloader/File.cpp
blob: 9e721a876efd84688fae13fe2030abe759029c90 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "File.hpp"

#include <cstring>

#include <openvic-dataloader/detail/Utility.hpp>

#include <lexy/encoding.hpp>

using namespace ovdl;

File::File(const char* path) : _path(path) {}

const char* File::path() const noexcept {
   return _path;
}

bool File::is_valid() const noexcept {
   return _buffer.index() != 0 && !_buffer.valueless_by_exception() && visit_buffer([](auto&& buffer) { return buffer.data() != nullptr; });
}

std::size_t File::size() const noexcept {
   return _buffer.index() != 0 && !_buffer.valueless_by_exception() ? _buffer_size : 0;
}