From: Alain Spineux Date: Fri, 10 Feb 2023 09:26:05 +0000 (+0100) Subject: win32: add helper function X-Git-Tag: Beta-15.0.0~252 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f8594d4ae0d84108423d2c2d7fd08cb1132876e;p=thirdparty%2Fbacula.git win32: add helper function - add win32_to_unix_slash() to compat.cpp simply replace any '\\' into '/' - add remove_win32_trailing_slash() to compat.cpp - add dump_name_list() to find.c for debuging fileset --- diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c index 3ebf30428..f6c569c00 100644 --- a/bacula/src/findlib/find.c +++ b/bacula/src/findlib/find.c @@ -572,3 +572,17 @@ term_find_files(FF_PKT *ff) free(ff); return hard_links; } + +/* dump the name_list of every include inside a FileSet */ +void dump_name_list(const char* file, int lineno, int lvl, const char *prefix, + findFILESET *fileset) +{ + for (int i=0; iinclude_list.size(); i++) { + findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i); + dlistString *node; + foreach_dlist(node, &incexe->name_list) { + Dmsg1(DT_VOLUME|50, "name_list = %s\n", node->c_str()); + if (chk_dbglvl(lvl)) d_msg(file, lineno, lvl, "%s INC[%d] name = %s\n", prefix, i, node->c_str()); + } + } +} diff --git a/bacula/src/findlib/find.h b/bacula/src/findlib/find.h index 8117d915e..f08dbbbc3 100644 --- a/bacula/src/findlib/find.h +++ b/bacula/src/findlib/find.h @@ -223,6 +223,8 @@ typedef void (mtab_handler_t)(void *user_ctx, struct stat *st, const char *fstype, const char *mountpoint, const char *mntopts, const char *fsname); bool read_mtab(mtab_handler_t *mtab_handler, void *user_ctx); +void dump_name_list(const char* file, int lineno, int lvl, const char *prefix, + findFILESET *fileset); #include "protos.h" diff --git a/bacula/src/win32/compat/compat.cpp b/bacula/src/win32/compat/compat.cpp index 77852de91..747e05024 100644 --- a/bacula/src/win32/compat/compat.cpp +++ b/bacula/src/win32/compat/compat.cpp @@ -652,6 +652,25 @@ wchar_win32_path(const char *name, wchar_t *win32_name) } #endif +/* simply replace any '\\' into '/' */ +void win32_to_unix_slash(char *name) +{ + for(char *p = name; *p ; p++) { + if (*p == '\\') { + *p = '/'; + } + } +} + +/* remove the trailing slashes if any */ +void remove_win32_trailing_slash(char *name) +{ + int l = strlen(name); + while (l > 0 && (name[l-1] == '/' || name[l-1] == '\\')) { + name[--l]='\0'; + } +} + /* * Convert a WUTF8 path into a normalized wchar windows path * Get the result from cache diff --git a/bacula/src/win32/compat/winapi.h b/bacula/src/win32/compat/winapi.h index f6966e8de..8093924ed 100644 --- a/bacula/src/win32/compat/winapi.h +++ b/bacula/src/win32/compat/winapi.h @@ -54,6 +54,8 @@ int wchar_path_2_wutf8(POOLMEM **pszUTF, const wchar_t *pszUCS); int wutf8_path_2_wchar(POOLMEM **ppszUCS, const char *pszUTF); int UTF8_2_wchar(POOLMEM **pszUCS, const char *pszUTF); int make_win32_path_UTF8_2_wchar(POOLMEM **pszUCS, const char *pszUTF, BOOL* pBIsRawPath = NULL); +void win32_to_unix_slash(char *name); +void remove_win32_trailing_slash(char *name); // init with win9x, but maybe set to NT in InitWinAPI extern DWORD DLL_IMP_EXP g_platform_id;