No need to stat with QFile::exists before QFile::open, for reading.
Change-Id: I14ca7f8a377bca39004defc96d69d62c151181f5 Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Jeremy Katz <jeremy.katz@nokia.com>
This commit is contained in:
parent
aee4cbf22a
commit
e5bcb4844d
@ -137,7 +137,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
|
||||
if (xdgConfigHome.isEmpty())
|
||||
xdgConfigHome = QDir::homePath() + QLatin1String("/.config");
|
||||
QFile file(xdgConfigHome + QLatin1String("/user-dirs.dirs"));
|
||||
if (file.exists() && file.open(QIODevice::ReadOnly)) {
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
QHash<QString, QString> lines;
|
||||
QTextStream stream(&file);
|
||||
// Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop"
|
||||
|
@ -255,7 +255,7 @@ quint64 QConnmanEngine::bytesWritten(const QString &id)
|
||||
quint64 result = 0;
|
||||
QString devFile = getInterfaceFromId(id);
|
||||
QFile tx("/sys/class/net/"+devFile+"/statistics/tx_bytes");
|
||||
if(tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
if (tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&tx);
|
||||
in >> result;
|
||||
tx.close();
|
||||
@ -270,7 +270,7 @@ quint64 QConnmanEngine::bytesReceived(const QString &id)
|
||||
quint64 result = 0;
|
||||
QString devFile = getInterfaceFromId(id);
|
||||
QFile rx("/sys/class/net/"+devFile+"/statistics/rx_bytes");
|
||||
if(rx.exists() && rx.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
if (rx.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&rx);
|
||||
in >> result;
|
||||
rx.close();
|
||||
|
@ -837,7 +837,7 @@ quint64 QNetworkManagerEngine::bytesWritten(const QString &id)
|
||||
quint64 result = Q_UINT64_C(0);
|
||||
|
||||
QFile tx(devFile);
|
||||
if (tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
if (tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&tx);
|
||||
in >> result;
|
||||
tx.close();
|
||||
@ -865,7 +865,7 @@ quint64 QNetworkManagerEngine::bytesReceived(const QString &id)
|
||||
quint64 result = Q_UINT64_C(0);
|
||||
|
||||
QFile tx(devFile);
|
||||
if (tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
if (tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&tx);
|
||||
in >> result;
|
||||
tx.close();
|
||||
|
@ -661,7 +661,7 @@ QString QGtkStylePrivate::getThemeName()
|
||||
foreach (const QString &rcPath, paths) {
|
||||
if (!rcPath.isEmpty()) {
|
||||
QFile rcFile(rcPath);
|
||||
if (rcFile.exists() && rcFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
if (rcFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&rcFile);
|
||||
while(!in.atEnd()) {
|
||||
QString line = in.readLine();
|
||||
|
Loading…
x
Reference in New Issue
Block a user