mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
buffer
This commit is contained in:
parent
4cfea36b93
commit
121747352d
@ -294,23 +294,19 @@ bool DetectorImpl::isAcquireReady() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string DetectorImpl::exec(const char *cmd) {
|
std::string DetectorImpl::exec(const char *cmd) {
|
||||||
int bufsize = 128;
|
char buffer[128];
|
||||||
char buffer[bufsize];
|
std::string result;
|
||||||
std::string result = "";
|
|
||||||
FILE *pipe = popen(cmd, "r");
|
FILE *pipe = popen(cmd, "r");
|
||||||
if (pipe == nullptr) {
|
if (pipe == nullptr) {
|
||||||
throw RuntimeError("Could not open pipe");
|
throw RuntimeError("Could not open pipe");
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
while (feof(pipe) == 0) {
|
while (feof(pipe) == 0) {
|
||||||
if (fgets(buffer, bufsize, pipe) != nullptr) {
|
if (fgets(buffer, sizeof(buffer), pipe) != nullptr) {
|
||||||
result += buffer;
|
result += buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (...) {
|
|
||||||
pclose(pipe);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
pclose(pipe);
|
pclose(pipe);
|
||||||
result.erase(result.find_last_not_of(" \t\n\r") + 1);
|
result.erase(result.find_last_not_of(" \t\n\r") + 1);
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user