mirror of
https://github.com/nitanmarcel/isodrive.git
synced 2026-03-13 04:17:24 +00:00
util: fix sysfs_write not writting to file
This commit is contained in:
+8
-13
@@ -58,17 +58,15 @@ bool isdir(char *path)
|
|||||||
void sysfs_write(char *path, char *content)
|
void sysfs_write(char *path, char *content)
|
||||||
{
|
{
|
||||||
std::cout << "Write: " << content << " -> " << path << std::endl;
|
std::cout << "Write: " << content << " -> " << path << std::endl;
|
||||||
int fd;
|
std::ofstream sysfsFile;
|
||||||
if (fd = open(path, O_WRONLY) == -1)
|
sysfsFile.open(path);
|
||||||
{
|
if (!sysfsFile.is_open()) {
|
||||||
perror("Failed to open sysfs file");
|
perror("Failed to open sysfs path");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (write(fd, content, strlen(content) == -1))
|
sysfsFile << content;
|
||||||
{
|
perror("Status");
|
||||||
perror("Failed to write sysfs file");
|
sysfsFile.close();
|
||||||
}
|
std::cout << std::endl;
|
||||||
close(fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -84,6 +82,3 @@ char *getprop(char *key)
|
|||||||
return value;
|
return value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user