浏览代码

#dump 修改

zxs 6 天之前
父节点
当前提交
7b341d766f
共有 2 个文件被更改,包括 17 次插入11 次删除
  1. 3 3
      CMakeLists.txt
  2. 14 8
      robot/robotics/dump.hpp

+ 3 - 3
CMakeLists.txt

@@ -21,7 +21,7 @@ elseif(UNIX)
     add_definitions(-DLINUX_BUILD)
 endif()
 # 包含子项目。
-# add_subdirectory ("robot")
-# add_subdirectory ("logger")
-# add_subdirectory ("drivers")
+add_subdirectory ("robot")
+add_subdirectory ("logger")
+add_subdirectory ("drivers")
 add_subdirectory ("generator")

+ 14 - 8
robot/robotics/dump.hpp

@@ -8,22 +8,26 @@
 *
 */
 #pragma once
-#ifdef WINDOWS_BUILD
-//widnows
-#include <Windows.h>
-#include <Dbghelp.h>
-#pragma comment (lib,"Dbghelp.lib")
 //stl
 #include <iostream>
 //robotics
 #include "logger.hpp"
 #include "datetime.hpp"
 
-#ifdef DUMP_INSTALL
-#else
+#ifndef DUMP_INSTALL
+#ifdef WINDOWS_BUILD
 #define DUMP_INSTALL robotics::v3::dump::install()
+#elif LINUX_BUILD
+#define DUMP_INSTALL
+#endif
 #endif // DUMP_INSTALL
 
+#ifdef WINDOWS_BUILD
+//widnows
+#include <Windows.h>
+#include <Dbghelp.h>
+#pragma comment (lib,"Dbghelp.lib")
+
 namespace robotics {
     namespace v3 {
         class dump {
@@ -79,7 +83,9 @@ namespace robotics {
             }
             static std::string get_dump_file_name() {
                 std::string currentTime = v3::datetime::current_datetime().to_string("yyyy_MM_dd_HH_mm_ss_fff");
-                std::filesystem::path path = std::filesystem::current_path();
+                char filename[512] = { 0 };
+                GetModuleFileNameA(NULL, filename, 512);
+                std::filesystem::path path = filename;
                 path /= "dump";
                 if (!std::filesystem::exists(path)) {
                     std::filesystem::create_directory(path);