From 28fee9400563c1d47bbda68f3af69d8f7dc2c37d Mon Sep 17 00:00:00 2001 From: zhangdaolong Date: Tue, 16 Dec 2025 17:33:50 +0800 Subject: [PATCH] Fix fullpath has double "/" --- post.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/post.cpp b/post.cpp index 7d0810d..36abce1 100644 --- a/post.cpp +++ b/post.cpp @@ -451,21 +451,25 @@ std::string PostData::get_full_path(const struct event *event) std::cout << "dir: dir1: " << event->dir1 << ", dir2: " << event->dir2 << ", dir3: " << event->dir3 << ", dir4: " << event->dir4 << ", filename: " << event->filename << std::endl; - if (event->dir4[0]) { + if (event->dir4[0] == '/') { fullpath += std::string(event->dir4) + std::string(event->dir3) + "/" + std::string(event->dir2) + "/" + std::string(event->dir1) + "/" + std::string(event->filename); + std::cout << "The 4 level fullpath: " << fullpath << std::endl; return fullpath; } - if (event->dir3[0]) { + if (event->dir3[0] == '/') { fullpath += std::string(event->dir3) + std::string(event->dir2) + "/" + std::string(event->dir1)+ "/" + std::string(event->filename); + std::cout << "The 3 level fullpath: " << fullpath << std::endl; return fullpath; } - if (event->dir2[0]) { + if (event->dir2[0] == '/') { fullpath += std::string(event->dir2) + std::string(event->dir1)+ "/" + std::string(event->filename); + std::cout << "The 2 level fullpath: " << fullpath << std::endl; return fullpath; } - if (event->dir1[0]) { + if (event->dir1[0] == '/') { fullpath += std::string(event->dir1) + std::string(event->filename); + std::cout << "The 1 level fullpath: " << fullpath << std::endl; return fullpath; } return fullpath; -- Gitee