6#include "roo_logging.h"
13String
subdir(String base,
const String& sub) {
27static uint8_t fromHexDigit(
char c) {
28 if (c >=
'0' && c <=
'9')
return c -
'0';
29 if (c >=
'A' && c <=
'F')
return c -
'A' + 10;
30 if (c >=
'a' && c <=
'f')
return c -
'a' + 10;
34static int64_t decodeHex(
const char* filename) {
36 for (
const char* c = filename; *c != 0; ++c) {
38 result |= (fromHexDigit(*c));
45std::vector<int64_t>
listFiles(roo_io::Mount& fs,
const char* dirname) {
46 std::vector<int64_t> result;
47 roo_io::Directory dir = fs.opendir(dirname);
49 LOG(WARNING) <<
"Failed to open directory " << dirname <<
": "
50 << roo_io::StatusAsString(dir.status());
54 if (dir.entry().isDirectory()) {
58 if (strlen(dir.entry().name()) != 12) {
62 result.push_back(decodeHex(dir.entry().name()));
64 std::sort(result.begin(), result.end());
71 for (
int i = 11; i >= 0; --i) {
Helper class for generating filenames corresponding to timestamps.
const char * filename() const
Returns the generated filename as a null-terminated string.
static Filename forTimestamp(int64_t nanosSinceEpoch)
Creates a filename for the specified timestamp.
Umbrella header for the roo_monitoring module.
const char * kLogSubPath
Subdirectory name used for raw log files.
String filepath(String dir, int64_t file)
Returns a file path for the given directory and timestamp-like value.
const char * kMonitoringBasePath
Base directory for monitoring storage on the filesystem.
std::vector< int64_t > listFiles(roo_io::Mount &fs, const char *dirname)
Lists timestamp-named files in the directory and returns their timestamps.
constexpr char toHexDigit(int d)
Converts a 0-15 value to an uppercase hex digit.
String subdir(String base, const String &sub)
Returns a path formed by joining the base directory and subdirectory.