Commit 8e5b2e1d authored by captainwong's avatar captainwong

update

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