-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfss.h
More file actions
51 lines (38 loc) · 1.34 KB
/
fss.h
File metadata and controls
51 lines (38 loc) · 1.34 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once
#include <string>
namespace fss {
std::string get_current_dir();
std::string get_current_exec_path();
bool file_exists(const std::string& name);
size_t get_file_size(const std::string& name);
std::string get_full_path(const std::string& path);
bool read_binary_file(const std::string& name, unsigned char* buffer);
/**
* @brief Reads file as string, returns empty string on error.
* @param name
* @return
*/
std::string read_all_text(const std::string& name);
// renamed to above function, for consistency
//std::string read_file_as_string(const std::string& name) { return read_all_text(name); }
/**
* @brief Writes all text to file, overwriting if exists.
* @param filename
* @param contents
*/
void write_all_text(const std::string& filename, const std::string& contents);
/**
* @brief Writes all text to file, appending if exists.
* @param filename
* @param contents
*/
void append_all_text(const std::string& filename, const std::string& contents);
/**
* @brief Calculates file age in seconds, from the creation time.
* @param filename
* @return
*/
unsigned int get_age_in_seconds(const std::string& filename);
std::string get_temp_file_path(const std::string& prefix = "TMP");
bool delete_file(const std::string& path);
}