예제 #1
0
파일: backup.c 프로젝트: tuxmux/bareos
/**
 * If requested strip leading components of the path so that we can
 * save file as if it came from a subdirectory.  This is most useful
 * for dealing with snapshots, by removing the snapshot directory, or
 * in handling vendor migrations where files have been restored with
 * a vendor product into a subdirectory.
 */
void strip_path(FF_PKT *ff_pkt)
{
   if (!bit_is_set(FO_STRIPPATH, ff_pkt->flags) || ff_pkt->strip_path <= 0) {
      Dmsg1(200, "No strip for %s\n", ff_pkt->fname);
      return;
   }

   if (!ff_pkt->fname_save) {
     ff_pkt->fname_save = get_pool_memory(PM_FNAME);
     ff_pkt->link_save = get_pool_memory(PM_FNAME);
   }

   pm_strcpy(ff_pkt->fname_save, ff_pkt->fname);
   if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) {
      pm_strcpy(ff_pkt->link_save, ff_pkt->link);
      Dmsg2(500, "strcpy link_save=%d link=%d\n", strlen(ff_pkt->link_save),
         strlen(ff_pkt->link));
      Dsm_check(200);
   }

   /**
    * Strip path. If it doesn't succeed put it back. If it does, and there
    * is a different link string, attempt to strip the link. If it fails,
    * back them both back. Do not strip symlinks. I.e. if either stripping
    * fails don't strip anything.
    */
   if (!do_strip(ff_pkt->strip_path, ff_pkt->fname)) {
      unstrip_path(ff_pkt);
      goto rtn;
   }

   /**
    * Strip links but not symlinks
    */
   if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) {
      if (!do_strip(ff_pkt->strip_path, ff_pkt->link)) {
         unstrip_path(ff_pkt);
      }
   }

rtn:
   Dmsg3(100, "fname=%s stripped=%s link=%s\n", ff_pkt->fname_save, ff_pkt->fname, ff_pkt->link);
}
예제 #2
0
inline
bool config_split_impl(io::Spanned<ZS> line, io::Spanned<XString> *key, io::Spanned<ZS> *value)
{
    // unconditionally fail if line contains control characters
    if (std::find_if(line.data.begin(), line.data.end(),
                [](unsigned char c) { return c < ' '; }
                ) != line.data.end())
        return false;

    if (!do_split(line, key, value))
        return false;
    *key = do_strip(*key);
    *value = do_lstrip(*value);
    return true;
}
예제 #3
0
파일: pystring.cpp 프로젝트: 400notout/oiio
 std::string rstrip( const std::string & str, const std::string & chars )
 {
     return do_strip( str, RIGHTSTRIP, chars );
 }
예제 #4
0
파일: pystring.cpp 프로젝트: 400notout/oiio
 std::string lstrip( const std::string & str, const std::string & chars )
 {
     return do_strip( str, LEFTSTRIP, chars );
 }
예제 #5
0
파일: pystring.cpp 프로젝트: 400notout/oiio
 std::string strip( const std::string & str, const std::string & chars )
 {
     return do_strip( str, BOTHSTRIP, chars );
 }
예제 #6
0
static PyObject *
strop_rstrip(PyObject *self, PyObject *args)
{
	WARN;
	return do_strip(args, RIGHTSTRIP);
}
예제 #7
0
static PyObject *
strop_lstrip(PyObject *self, PyObject *args)
{
	WARN;
	return do_strip(args, LEFTSTRIP);
}
예제 #8
0
static PyObject *
strop_strip(PyObject *self, PyObject *args)
{
	WARN;
	return do_strip(args, BOTHSTRIP);
}