mirror of
https://github.com/nitanmarcel/isodrive.git
synced 2026-03-13 04:17:24 +00:00
util: fix reading sysfs
This commit is contained in:
14
src/util.cpp
14
src/util.cpp
@@ -65,14 +65,20 @@ void sysfs_write(char *path, char *content)
|
||||
|
||||
char *sysfs_read(char *path)
|
||||
{
|
||||
char *value = nullptr;
|
||||
std::string value;
|
||||
std::ifstream sysfsFile(path);
|
||||
sysfsFile >> path;
|
||||
if (!sysfsFile.is_open())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
sysfsFile >> value;
|
||||
sysfsFile.close();
|
||||
return value;
|
||||
char *result = new char[value.length() + 1];
|
||||
strcpy(result, value.c_str());
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
char *getprop(char *key)
|
||||
{
|
||||
std::array<char, 128> buffer;
|
||||
|
||||
Reference in New Issue
Block a user