 ===================================================================
 --- src/dird/dird_conf.c	(rvision 4466)
 +++ src/dird/dird_conf.c	(copie de travail)
-@@ -268,6 +268,7 @@
+@@ -52,6 +52,7 @@
+ 
+ #include "bacula.h"
+ #include "dird.h"
++#include "lib/breg.h"
+ 
+ /* Define the first and last resource ID record
+  * types. Note, these should be unique for each
+@@ -268,6 +269,10 @@
     {"run",       store_alist_str, ITEM(res_job.run_cmds), 0, 0, 0},
     /* Root of where to restore files */
     {"where",    store_dir,      ITEM(res_job.RestoreWhere), 0, 0, 0},
 +   {"whereuseregexp", store_bool, ITEM(res_job.where_use_regexp), 0, 0, 0},
++   {"stripprefix",    store_str,  ITEM(res_job.strip_prefix), 0, 0, 0},
++   {"addprefix",    store_str,  ITEM(res_job.add_prefix), 0, 0, 0},
++   {"addsuffix",    store_str,  ITEM(res_job.add_suffix), 0, 0, 0},
     /* Where to find bootstrap during restore */
     {"bootstrap",store_dir,      ITEM(res_job.RestoreBootstrap), 0, 0, 0},
     /* Where to write bootstrap file during backup */
-@@ -611,6 +612,9 @@
+@@ -611,6 +616,9 @@
        if (res->res_job.RestoreWhere) {
           sendit(sock, _("  --> Where=%s\n"), NPRT(res->res_job.RestoreWhere));
        }

===================================================================
--- src/dird/dird_conf.h	(rvision 4466)
+++ src/dird/dird_conf.h	(copie de travail)
@@ -356,6 +356,7 @@
    int   Priority;                    /* Job priority */
    int   RestoreJobId;                /* What -- JobId to restore */
    char *RestoreWhere;                /* Where on disk to restore -- directory */
+   bool  where_use_regexp;            /* true if RestoreWhere is a BREGEXP */
    char *RestoreBootstrap;            /* Bootstrap file */
    alist *RunScripts;                 /* Run {client} program {after|before} Job */

       if (res->res_job.RestoreBootstrap) {
          sendit(sock, _("  --> Bootstrap=%s\n"), NPRT(res->res_job.RestoreBootstrap));
       }
@@ -1143,6 +1151,15 @@
       if (res->res_job.RestoreWhere) {
          free(res->res_job.RestoreWhere);
       }
+      if (res->res_job.strip_prefix) {
+         free(res->res_job.strip_prefix);
+      }
+      if (res->res_job.add_prefix) {
+         free(res->res_job.add_prefix);
+      }
+      if (res->res_job.add_suffix) {
+         free(res->res_job.add_suffix);
+      }
       if (res->res_job.RestoreBootstrap) {
          free(res->res_job.RestoreBootstrap);
       }
@@ -1299,6 +1316,19 @@
          res->res_job.jobdefs    = res_all.res_job.jobdefs;
          res->res_job.run_cmds   = res_all.res_job.run_cmds;
          res->res_job.RunScripts = res_all.res_job.RunScripts;
+	 if (res->res_job.strip_prefix ||
+	     res->res_job.add_suffix   ||
+	     res->res_job.add_prefix)
+	 {
+	    if (res->res_job.RestoreWhere) {
+	       free(res->res_job.RestoreWhere);
+	    }
+	    res->res_job.where_use_regexp = true;
+	    res->res_job.RestoreWhere=bregexp_build_where(res->res_job.strip_prefix,
+							  res->res_job.add_prefix,
+							  res->res_job.add_suffix);
+	    /* TODO: test bregexp */
+	 }
          break;
       case R_COUNTER:
          if ((res = (URES *)GetResWithName(R_COUNTER, res_all.res_counter.hdr.name)) == NULL) {
Index: src/dird/ua_run.c
===================================================================
--- src/dird/ua_run.c	(rvision 4466)
