bool get_team_name_and_icon(info_pack& infoPack, bool icon) { BPath systemPath; find_directory(B_BEOS_SYSTEM_DIRECTORY, &systemPath); bool nameFromArgs = false; bool tryTrackerIcon = true; for (int len = strlen(infoPack.team_info.args) - 1; len >= 0 && infoPack.team_info.args[len] == ' '; len--) { infoPack.team_info.args[len] = 0; } app_info info; status_t status = be_roster->GetRunningAppInfo(infoPack.team_info.team, &info); if (status == B_OK || infoPack.team_info.team == B_SYSTEM_TEAM) { if (infoPack.team_info.team == B_SYSTEM_TEAM) { // Get icon and name from kernel system_info systemInfo; get_system_info(&systemInfo); BPath kernelPath(systemPath); kernelPath.Append(systemInfo.kernel_name); get_ref_for_path(kernelPath.Path(), &info.ref); nameFromArgs = true; } } else { BEntry entry(infoPack.team_info.args, true); status = entry.GetRef(&info.ref); if (status != B_OK || strncmp(infoPack.team_info.args, systemPath.Path(), strlen(systemPath.Path())) != 0) nameFromArgs = true; tryTrackerIcon = (status == B_OK); } strncpy(infoPack.team_name, nameFromArgs ? infoPack.team_info.args : info.ref.name, B_PATH_NAME_LENGTH - 1); if (icon) { #ifdef __HAIKU__ infoPack.team_icon = new BBitmap(BRect(0, 0, 15, 15), B_RGBA32); #else infoPack.team_icon = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8); #endif if (!tryTrackerIcon || BNodeInfo::GetTrackerIcon(&info.ref, infoPack.team_icon, B_MINI_ICON) != B_OK) { // TODO: don't hardcode the "app" icon! infoPack.team_icon->SetBits(k_app_mini, 256, 0, B_CMAP8); } } else infoPack.team_icon = NULL; return true; }
qint64 linuxswap::readUsedCapacity(const QString& deviceNode) const { QFile swapsFile(QStringLiteral("/proc/swaps")); if (swapsFile.open(QIODevice::ReadOnly)) { QByteArray data = swapsFile.readAll(); swapsFile.close(); QTextStream in(&data); while (!in.atEnd()) { QStringList line = in.readLine().split(QRegExp(QStringLiteral("\\s+"))); QFileInfo kernelPath(deviceNode); if (line[0] == kernelPath.canonicalFilePath()) return line[3].toLongLong() * 1024; } } return -1; }