binpac: Additional Windows fixes. Fixed wrong MSVC macro definition and std::filesystem invocation. Linking to libunistd library

This commit is contained in:
Tomer Lev 2022-10-24 16:34:57 +03:00 committed by Tim Wojtulewicz
parent 60265b8ce7
commit 9a4e01e634
2 changed files with 4 additions and 4 deletions

View file

@ -106,7 +106,7 @@ set(binpac_SRCS
add_executable(binpac ${binpac_SRCS}) add_executable(binpac ${binpac_SRCS})
if ( MSVC ) if ( MSVC )
target_link_libraries(binpac PRIVATE zeek_windows) target_link_libraries(binpac PRIVATE libunistd)
endif() endif()
install(TARGETS binpac DESTINATION bin) install(TARGETS binpac DESTINATION bin)

View file

@ -24,7 +24,7 @@
#include <errno.h> #include <errno.h>
#include <string_view> #include <string_view>
#ifdef MSVC #ifdef _MSC_VER
#include <filesystem> #include <filesystem>
#else #else
#include <libgen.h> #include <libgen.h>
@ -52,8 +52,8 @@ void include_file(const char *filename);
std::string do_dirname(std::string_view s) std::string do_dirname(std::string_view s)
{ {
#ifdef MSVC #ifdef _MSC_VER
return std::filesystem::path(path).parent_path().string(); return std::filesystem::path(s).parent_path().string();
#else #else
std::unique_ptr<char[]> tmp{new char[s.size()+1]}; std::unique_ptr<char[]> tmp{new char[s.size()+1]};
strncpy(tmp.get(), s.data(), s.size()); strncpy(tmp.get(), s.data(), s.size());