Commit 8e5b2e1d authored by captainwong's avatar captainwong

update

parent aec2ca96
......@@ -3,7 +3,7 @@
#include <memory>
#include <list>
#include <mutex>
#include <boost/noncopyable.hpp>
#include "../base/noncopyable.h"
namespace jlib {
namespace dp {
......@@ -17,7 +17,7 @@ public:
template <typename target>
class observable : public boost::noncopyable
class observable : public noncopyable
{
public:
typedef observer<target> observer_type;
......
#pragma once
#include <memory>
#include <mutex>
#include <boost/noncopyable.hpp>
#include "../base/noncopyable.h"
namespace jlib {
namespace dp {
template <class T>
class singleton : public boost::noncopyable
class singleton : public noncopyable
{
protected:
static std::shared_ptr<T> instance_;
......
......@@ -18,9 +18,8 @@
#include <cstdint>
#include <cstdarg>
#include <algorithm>
#include <boost/noncopyable.hpp>
#include "utf8.h"
#include "chrono_wrapper.h"
#include "util/chrono_wrapper.h"
#include "dp/singleton.h"
namespace jlib
......@@ -171,7 +170,7 @@ public:
*p = '\0';
#if defined(WIN32)
auto msg = instance->format_msg(utf8::u16_to_mbcs(buf));
auto msg = instance->format_msg(win32::utf16_to_mbcs(buf));
#else
auto msg = instance->format_msg(utf8::w2a(buf));
#endif
......@@ -208,7 +207,7 @@ public:
}
std::string format_msg(const std::string& msg) {
return line_prefix_ + " " + now_to_string(true) + " ---- " + msg;
return line_prefix_ + " " + nowToString(true) + " ---- " + msg;
}
......@@ -229,7 +228,7 @@ protected:
}
void create_file_name() {
auto s = now_to_string();
auto s = nowToString();
std::replace(s.begin(), s.end(), ' ', '_');
std::replace(s.begin(), s.end(), ':', '-');
log_file_path_ = log_file_foler_ + log_file_prefix_ + "." + s + ".log";
......
......@@ -16,13 +16,17 @@ std::vector<DiskDrive> disk_drives()
if (wmi::WmiBase::simpleSelect({ L"DeviceID", L"Index", L"Model", L"Partitions", L"SerialNumber", L"Size", }, L"Win32_DiskDrive", L"", result)) {
for (auto& item : result) {
DiskDrive drive;
drive.device_id = utf16_to_mbcs(item[L"DeviceID"]);
drive.index = std::stoi(item[L"Index"]);
drive.model = utf16_to_mbcs(item[L"Model"]);
drive.partitions = std::stoi(item[L"Partitions"]);
drive.serial = utf16_to_mbcs(item[L"SerialNumber"]);
drive.size = std::stoull(item[L"Size"]);
drives.push_back(drive);
try {
drive.index = std::stoi(item[L"Index"]);
drive.partitions = std::stoi(item[L"Partitions"]);
drive.size = std::stoull(item[L"Size"]);
drive.device_id = utf16_to_mbcs(item[L"DeviceID"]);
drive.model = utf16_to_mbcs(item[L"Model"]);
drive.serial = utf16_to_mbcs(item[L"SerialNumber"]);
drives.push_back(drive);
} catch (...) {
}
}
}
......
......@@ -15,7 +15,16 @@ std::vector<Gpu> gpus()
for (auto&& item : result) {
Gpu gpu;
gpu.name = utf16_to_mbcs(item[L"Description"]);
gpu.memsz = std::stoull(item[L"AdapterRAM"]);
try {
gpu.memsz = std::stoull(item[L"AdapterRAM"]);
} catch (...) {
try {
gpu.name = utf16_to_mbcs(item[L"AdapterRAM"]);
gpu.memsz = std::stoull(item[L"Description"]);
} catch (...) {
gpu.memsz = 0;
}
}
gs.push_back(gpu);
}
}
......
......@@ -42,8 +42,12 @@ std::vector<LogicalDrive> logical_drives()
LogicalDrive drive;
drive.device_id = utf16_to_mbcs(item[L"DeviceID"]);
drive.drive_type = parseDriveType(item[L"DriveType"]);
drive.free_space = std::stoull(item[L"FreeSpace"]);
drive.size = std::stoull(item[L"Size"]);
try {
drive.free_space = std::stoull(item[L"FreeSpace"]);
drive.size = std::stoull(item[L"Size"]);
} catch (...) {
}
drive.volume_name = utf16_to_mbcs(item[L"VolumeName"]);
drives.push_back(drive);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment