Refactored read methods

This commit is contained in:
Linus Dierheimer
2022-06-20 16:27:33 +02:00
parent 6e731c80d0
commit 8fa09ca093
12 changed files with 53 additions and 39 deletions
+2 -2
View File
@@ -337,7 +337,7 @@ static void getFromProcDir(const FFinstance* instance, FFDisplayServerResult* re
//Don't check for processes not owend by the current user.
ffStrbufAppendS(&procPath, "/loginuid");
ffGetFileContent(procPath.chars, &loginuid);
ffGetFileBuffer(procPath.chars, &loginuid);
if(ffStrbufComp(&userID, &loginuid) != 0)
{
ffStrbufSubstrBefore(&procPath, procPathLength);
@@ -348,7 +348,7 @@ static void getFromProcDir(const FFinstance* instance, FFDisplayServerResult* re
//We check the cmdline for the process name, because it is not trimmed.
ffStrbufAppendS(&procPath, "/cmdline");
ffGetFileContent(procPath.chars, &processName);
ffGetFileBuffer(procPath.chars, &processName);
ffStrbufSubstrBeforeFirstC(&processName, '\0'); //Trim the arguments
ffStrbufSubstrAfterLastC(&processName, '/');
+3 -3
View File
@@ -32,7 +32,7 @@ static bool parseHwmonDir(FFstrbuf* dir, FFTempValue* value)
continue;
ffStrbufAppendS(dir, dirent->d_name);
ffGetFileContent(dir->chars, &valueString);
ffGetFileBuffer(dir->chars, &valueString);
ffStrbufSubstrBefore(dir, dirLength);
//ffStrbufToDouble() returns NaN if the string couldn't be parsed
@@ -51,11 +51,11 @@ static bool parseHwmonDir(FFstrbuf* dir, FFTempValue* value)
return false;
ffStrbufAppendS(dir, "name");
ffGetFileContent(dir->chars, &value->name);
ffGetFileBuffer(dir->chars, &value->name);
ffStrbufSubstrBefore(dir, dirLength);
ffStrbufAppendS(dir, "device/class");
ffGetFileContent(dir->chars, &value->deviceClass);
ffGetFileBuffer(dir->chars, &value->deviceClass);
ffStrbufSubstrBefore(dir, dirLength);
return value->name.length > 0 || value->deviceClass.length > 0;
+1 -1
View File
@@ -21,7 +21,7 @@ static void getProcessInformation(const char* pid, FFstrbuf* processName, FFstrb
ffStrbufAppendS(&cmdlineFilePath, pid);
ffStrbufAppendS(&cmdlineFilePath, "/cmdline");
ffGetFileContent(cmdlineFilePath.chars, exe);
ffGetFileBuffer(cmdlineFilePath.chars, exe);
ffStrbufSubstrBeforeFirstC(exe, '\0'); //Trim the arguments
ffStrbufTrimLeft(exe, '-'); //Happens in TTY