add volume widget
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
class SystemHelper
|
||||
{
|
||||
@@ -25,4 +28,18 @@ class SystemHelper
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Read an entire file into a string. Throws std::runtime_error on failure.
|
||||
static std::string read_file_to_string(const std::string &path)
|
||||
{
|
||||
std::ifstream in(path, std::ios::in | std::ios::binary);
|
||||
if (!in)
|
||||
{
|
||||
throw std::runtime_error("Failed to open file: " + path);
|
||||
}
|
||||
|
||||
std::ostringstream ss;
|
||||
ss << in.rdbuf();
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user