mirror of
https://github.com/nitanmarcel/isodrive.git
synced 2026-03-13 04:17:24 +00:00
isodrive: fix usb gadget
- correctly get gadget - fix writing to sysfs - allow umounting iso
This commit is contained in:
21
src/util.cpp
21
src/util.cpp
@@ -9,7 +9,7 @@
|
||||
#include <sstream>
|
||||
#include <array>
|
||||
#include <memory>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
// https://stackoverflow.com/a/123724
|
||||
void trim(char *s)
|
||||
@@ -58,15 +58,18 @@ bool isdir(char *path)
|
||||
void sysfs_write(char *path, char *content)
|
||||
{
|
||||
std::cout << "Write: " << content << " -> " << path << std::endl;
|
||||
std::ofstream sysfsFile;
|
||||
sysfsFile.open(path);
|
||||
if (!sysfsFile.is_open()) {
|
||||
perror("Failed to open sysfs path");
|
||||
}
|
||||
sysfsFile << content;
|
||||
perror("Status");
|
||||
std::ofstream sysfsFile(path);
|
||||
sysfsFile << content << std::endl;
|
||||
sysfsFile.close();
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
char *sysfs_read(char *path)
|
||||
{
|
||||
char *value = nullptr;
|
||||
std::ifstream sysfsFile(path);
|
||||
sysfsFile >> path;
|
||||
sysfsFile.close();
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user