mirror of
https://github.com/otakuto/crazydiskinfo.git
synced 2025-07-23 06:35:49 +00:00
For avoiding crash, exit with error message if no devices or non-root user
This commit is contained in:
parent
e8d09408a3
commit
d39417c165
1 changed files with 8 additions and 1 deletions
9
main.cpp
9
main.cpp
|
@ -428,6 +428,14 @@ int main()
|
||||||
}
|
}
|
||||||
std::sort(smartList.begin(), smartList.end(), [](auto lhs, auto rhs){return lhs.deviceName < rhs.deviceName;});
|
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;
|
WINDOW * windowVersion;
|
||||||
windowVersion = newwin(1, width, 0, 0);
|
windowVersion = newwin(1, width, 0, 0);
|
||||||
|
|
||||||
|
@ -503,4 +511,3 @@ int main()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue