From 32d2f7344a76174ff9c09b3a696be08cc4103c67 Mon Sep 17 00:00:00 2001 From: wenli7363 Date: Thu, 21 Dec 2023 09:47:39 +0800 Subject: [PATCH] fix APPDIR env bug --- ZpodsLib/src/base/compress.h | 2 +- ZpodsLib/src/core/zpods_core.h | 2 +- network/client/grpc_client.cpp | 8 +++++++- scripts/test.sh | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ZpodsLib/src/base/compress.h b/ZpodsLib/src/base/compress.h index f4fa5ba..2c64e5c 100644 --- a/ZpodsLib/src/base/compress.h +++ b/ZpodsLib/src/base/compress.h @@ -165,7 +165,7 @@ struct fmt::formatter template auto format(const Code& p, FormatContext& ctx) const { - return format_to(ctx.out(), "0b{:0{}b}", p.bits, p.len); + return fmt::format_to(ctx.out(), "0b{:0{}b}", p.bits, p.len); } }; diff --git a/ZpodsLib/src/core/zpods_core.h b/ZpodsLib/src/core/zpods_core.h index fab6978..ccc374e 100644 --- a/ZpodsLib/src/core/zpods_core.h +++ b/ZpodsLib/src/core/zpods_core.h @@ -225,7 +225,7 @@ struct fmt::formatter template auto format(const zpods::Pea& p, FormatContext& ctx) const { - return format_to(ctx.out(), "rel_path: {}, last_modified_ts: {}", + return fmt::format_to(ctx.out(), "rel_path: {}, last_modified_ts: {}", p.rel_path, p.last_modified_ts); } }; diff --git a/network/client/grpc_client.cpp b/network/client/grpc_client.cpp index 3488f6d..8b5542a 100644 --- a/network/client/grpc_client.cpp +++ b/network/client/grpc_client.cpp @@ -9,7 +9,13 @@ ABSL_FLAG(std::string, target, "127.0.0.1:50051", "Server address"); auto MakeClientSslCredentials() { auto ReadFile = [](const std::string& filename) { - let filepath = zpods::fs::path(getenv("APPDIR")) / filename; + let filepath = filename; + + const char* appDir = getenv("APPDIR"); + if(appDir != nullptr) + { + filepath = zpods::fs::path(getenv("APPDIR")) / filename; + } std::ifstream file(filepath); std::stringstream buffer; diff --git a/scripts/test.sh b/scripts/test.sh index 00e2f64..caebb9a 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,5 +1,7 @@ #!/bin/bash +mkdir tmp cd build ./ZpodsLib/test/zpods_lib_test cd .. +rm -rf tmp \ No newline at end of file