forked from JayXon/Leanify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileio.h
More file actions
19 lines (14 loc) · 662 Bytes
/
Copy pathfileio.h
File metadata and controls
19 lines (14 loc) · 662 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef FILEIO_H_
#define FILEIO_H_
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <optional>
#include <vector>
// Read entire file into a vector. Returns nullopt on error, empty vector for empty files.
std::optional<std::vector<uint8_t>> ReadFile(const std::filesystem::path& filepath);
// Write data to file atomically (temp file + rename). Returns true on success.
bool WriteFile(const std::filesystem::path& filepath, const uint8_t* data, size_t size);
// Collect all regular files under a path (recursively for directories).
std::vector<std::filesystem::path> CollectFiles(const std::filesystem::path& path);
#endif // FILEIO_H_