Hi Thien,
If d_name = "abcd1_123xxx" and file_name_find_g = "abc", then your code still
match.
Can you try to use regex which is available in c++11?
For example:
#include <regex>
...
std::regex pattern1(file_name_find_g + "_[0-9]+_[0-9]+.log");
std::regex pattern2(file_name_find_g + "_[0-9]+_[0-9]+_[0-9]+_[0-9]+.log");
if (std::regex_match(finfo->d_name, pattern1) ||
std::regex_match(finfo->d_name, pattern2)) {
...
}
Not yet verify, just the idea.
Best Regards,
ThuanTr
-----Original Message-----
From: Thien Minh Huynh <[email protected]>
Sent: Tuesday, April 7, 2020 1:21 PM
To: Thuan Tran <[email protected]>; Vu Minh Nguyen
<[email protected]>
Cc: [email protected]; Thien Minh Huynh
<[email protected]>
Subject: [PATCH 1/1] log: log content is placed in a file of another stream
[#3175]
---
src/log/logd/lgs_filehdl.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/log/logd/lgs_filehdl.cc b/src/log/logd/lgs_filehdl.cc
index 0d7fb2b74..238259454 100644
--- a/src/log/logd/lgs_filehdl.cc
+++ b/src/log/logd/lgs_filehdl.cc
@@ -965,8 +965,10 @@ static int chr_cnt_b(char *str, char c, int lim) {
static std::string file_name_find_g;
static int filter_logfile_name(const struct dirent *finfo) {
int found = 0;
+ int len = file_name_find_g.length();
- if ((strstr(finfo->d_name, file_name_find_g.c_str()) != nullptr) &&
+ if ((strncmp(finfo->d_name, file_name_find_g.c_str(), len) == 0) &&
+ isdigit(finfo->d_name[len + 1]) &&
(strstr(finfo->d_name, ".log") != nullptr))
found = 1;
--
2.17.1
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel