154 lines
5.4 KiB
C++
154 lines
5.4 KiB
C++
/*! \file pisysteminfo.h
|
|
* \ingroup System
|
|
* \~\brief
|
|
* \~english System information
|
|
* \~russian Информация о системе
|
|
*/
|
|
/*
|
|
PIP - Platform Independent Primitives
|
|
System information
|
|
Ivan Pelipenko peri4ko@yandex.ru
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef PISYSTEMINFO_H
|
|
#define PISYSTEMINFO_H
|
|
|
|
#include "pitime.h"
|
|
|
|
|
|
//! \~\ingroup System
|
|
//! \~\brief
|
|
//! \~english System information class.
|
|
//! \~russian Класс информации о системе.
|
|
//! \~\details
|
|
//! \~english Provides system information such as mount points, machine key, and system details
|
|
//! \~russian Предоставляет информацию о системе, такую как точки монтирования, уникальный ключ и детали системы
|
|
class PIP_EXPORT PISystemInfo {
|
|
public:
|
|
//! \~\ingroup System
|
|
//! \~\brief
|
|
//! \~english Mount point information structure.
|
|
//! \~russian Структура информации о точке монтирования.
|
|
struct PIP_EXPORT MountInfo {
|
|
//! \~english Absolute path to mount point
|
|
//! \~russian Абсолютный путь к точке монтирования
|
|
PIString mount_point;
|
|
|
|
//! \~english Device description
|
|
//! \~russian Описание устройства
|
|
PIString device;
|
|
|
|
//! \~english Filesystem name
|
|
//! \~russian Имя файловой системы
|
|
PIString filesystem;
|
|
|
|
//! \~english Mount point label
|
|
//! \~russian Метка точки монтирования
|
|
PIString label;
|
|
|
|
//! \~english Total space in bytes
|
|
//! \~russian Полный объем в байтах
|
|
ullong space_all = 0;
|
|
|
|
//! \~english Used space in bytes
|
|
//! \~russian Занятый объем в байтах
|
|
ullong space_used = 0;
|
|
|
|
//! \~english Free space in bytes
|
|
//! \~russian Свободный объем в байтах
|
|
ullong space_free = 0;
|
|
|
|
//! \~english Is this device is removable
|
|
//! \~russian Является ли устройство съёмным
|
|
bool removable = false;
|
|
};
|
|
|
|
//! \~english Absolute path to "ifconfig" utility.
|
|
//! \~russian Абсолютный путь к утилите "ifconfig".
|
|
PIString ifconfigPath;
|
|
|
|
//! \~english Application execution path (\c argv[0]).
|
|
//! \~russian Путь вызова приложения (\c argv[0]).
|
|
PIString execCommand;
|
|
|
|
//! \~english System hostname.
|
|
//! \~russian Hostname системы.
|
|
PIString hostname;
|
|
|
|
//! \~english Username that starts application.
|
|
//! \~russian Имя пользователя, запустившего приложение.
|
|
PIString user;
|
|
|
|
//! \~english System name (Windows, MacOS, ...).
|
|
//! \~russian Имя системы (Windows, MacOS, ...).
|
|
PIString OS_name;
|
|
|
|
//! \~english System version.
|
|
//! \~russian Версия системы.
|
|
PIString OS_version;
|
|
|
|
//! \~english System architecture (x86, x86_64, ...).
|
|
//! \~russian Архитектура системы (x86, x86_64, ...).
|
|
PIString architecture;
|
|
|
|
//! \~english Application start date and time.
|
|
//! \~russian Дата и время запуска приложения.
|
|
PIDateTime execDateTime;
|
|
|
|
//! \~english System logical processors count.
|
|
//! \~russian Количество логических процессоров системы.
|
|
int processorsCount = 1;
|
|
|
|
//! \~english Returns all mount points absolute pathes.
|
|
//! \~russian Возвращает абсолютные пути всех точек монтирования.
|
|
static PIStringList mountRoots();
|
|
|
|
//! \~english Returns information of all mount points.
|
|
//! \~russian Возвращает информацию о всех точках монтирования.
|
|
static PIVector<MountInfo> mountInfo(bool ignore_cache = false);
|
|
|
|
//! \~english Returns system unique key.
|
|
//! \~russian Возвращает уникальный ключ системы.
|
|
static PIString machineKey();
|
|
|
|
//! \~english Returns system unique key hash.
|
|
//! \~russian Возвращает хэш уникального ключа системы.
|
|
static uint machineID();
|
|
|
|
//! \~english Returns singleton of %PISystemInfo.
|
|
//! \~russian Возвращает синглтон %PISystemInfo.
|
|
static PISystemInfo * instance();
|
|
|
|
private:
|
|
PISystemInfo() {}
|
|
NO_COPY_CLASS(PISystemInfo);
|
|
};
|
|
|
|
|
|
//! \relatesalso PICout
|
|
//! \~english Output operator to \a PICout.
|
|
//! \~russian Оператор вывода в \a PICout.
|
|
inline PICout operator<<(PICout s, const PISystemInfo::MountInfo & v) {
|
|
s.saveAndSetControls(0);
|
|
s << "MountInfo(" << v.device << " mounted on \"" << v.mount_point << "\", type " << v.filesystem << ", label \"" << v.label
|
|
<< "\", all " << PIString::readableSize(v.space_all) << ", used " << PIString::readableSize(v.space_used) << ", free "
|
|
<< PIString::readableSize(v.space_free) << ")";
|
|
s.restoreControls();
|
|
return s;
|
|
}
|
|
|
|
#endif // PISYSTEMINFO_H
|