]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
win32: add helper function
authorAlain Spineux <alain@baculasystems.com>
Fri, 10 Feb 2023 09:26:05 +0000 (10:26 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:57:01 +0000 (13:57 +0200)
- 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

bacula/src/findlib/find.c
bacula/src/findlib/find.h
bacula/src/win32/compat/compat.cpp
bacula/src/win32/compat/winapi.h

index 3ebf30428b349dc3f4f99887f9807aed5eb35937..f6c569c0050156b1388d793c77d332335d2628fd 100644 (file)
@@ -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; i<fileset->include_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());
+      }
+   }
+}
index 8117d915ef0f7f470582b2fcd109c16e7b9dc6ce..f08dbbbc39bdfc457a2a7456a7efdebd5db42099 100644 (file)
@@ -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"
 
index 77852de91f3978a00f3299cc8ee45d277cf39913..747e050240bae0f63dea2d399795d5ca7d8c500b 100644 (file)
@@ -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
index f6966e8dee1c6df55bf538703b5b28284cc0105e..8093924ed678bfa81048aa13ae51a57dd6eed821 100644 (file)
@@ -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;