1
0
Fork 0
mirror of https://github.com/otakuto/crazydiskinfo.git synced 2025-07-22 22:25:27 +00:00

For avoiding crash, exit with error message if no devices or non-root user

This commit is contained in:
Takanori Suzuki 2017-01-24 18:57:09 +09:00 committed by otakuto
parent e8d09408a3
commit d39417c165

View file

@ -428,6 +428,14 @@ int main()
}
std::sort(smartList.begin(), smartList.end(), [](auto lhs, auto rhs){return lhs.deviceName < rhs.deviceName;});
if (smartList.size() == 0)
{
endwin();
std::cerr << "No S.M.A.R.T readable devices." << std::endl;
std::cerr << "If you are non-root user, please use sudo or become root." << std::endl;
return 1;
}
WINDOW * windowVersion;
windowVersion = newwin(1, width, 0, 0);
@ -503,4 +511,3 @@ int main()
}
}
}