src/cats/sql.c
void split_path_and_file(JCR *jcr, BDB *mdb, const char *afname) 
{ 
   const char *p, *f; 
 
   /* Find path without the filename. 
    * I.e. everything after the last / is a "filename". 
    * OK, maybe it is a directory name, but we treat it like 
    * a filename. If we don't find a / then the whole name 
    * must be a path name (e.g. c:). 
    */ 
   for (p=f=afname; *p; p++) { 
      if (IsPathSeparator(*p)) { 
         f = p;                       /* set pos of last slash */ 
      } 
   } 
   if (IsPathSeparator(*f)) {                   /* did we find a slash? */ 
      f++;                            /* yes, point to filename */ 
   } else {                           /* no, whole thing must be path name */ 
      f = p; 
   } 
 
   /* If filename doesn't exist (i.e. root directory), we 
    * simply create a blank name consisting of a single 
    * space. This makes handling zero length filenames 
    * easier. 
    */ 
   mdb->fnl = p - f; 
   if (mdb->fnl > 0) { 
      mdb->fname = check_pool_memory_size(mdb->fname, mdb->fnl+1); 
      memcpy(mdb->fname, f, mdb->fnl);    /* copy filename */ 
      mdb->fname[mdb->fnl] = 0; 
   } else { 
      mdb->fname[0] = 0; 
      mdb->fnl = 0; 
   } 
 
   mdb->pnl = f - afname; 
   if (mdb->pnl > 0) { 
      mdb->path = check_pool_memory_size(mdb->path, mdb->pnl+1); 
      memcpy(mdb->path, afname, mdb->pnl); 
      mdb->path[mdb->pnl] = 0; 
   } else { 
      Mmsg1(&mdb->errmsg, _("Path length is zero. File=%s\n"), afname); 
      Jmsg(jcr, M_FATAL, 0, "%s", mdb->errmsg); 
      mdb->path[0] = 0; 
      mdb->pnl = 0; 
   } 
 
   Dmsg3(500, "split fname=%s: path=%s file=%s\n", afname, mdb->path, mdb->fname); 
}
/* 
 * Given a full filename, split it into its path 
 *  and filename parts. They are returned in pool memory 
 *  in the mdb structure. 
 */
Given a full filename, split it into its path
and filename parts. They are returned in pool memory
in the mdb structure.
Given a full filename split it into its path and filename parts . They are returned in pool memory in the mdb structure .
void split_path_and_file(JCR *jcr, BDB *mdb, const char *afname) 
{ 
   const char *p, *f; 
   for (p=f=afname; *p; p++) { 
      if (IsPathSeparator(*p)) { 
         f = p;                        
      } 
   } 
   if (IsPathSeparator(*f)) {                    
      f++;                             
   } else {                            
      f = p; 
   } 
   mdb->fnl = p - f; 
   if (mdb->fnl > 0) { 
      mdb->fname = check_pool_memory_size(mdb->fname, mdb->fnl+1); 
      memcpy(mdb->fname, f, mdb->fnl);     
      mdb->fname[mdb->fnl] = 0; 
   } else { 
      mdb->fname[0] = 0; 
      mdb->fnl = 0; 
   } 
   mdb->pnl = f - afname; 
   if (mdb->pnl > 0) { 
      mdb->path = check_pool_memory_size(mdb->path, mdb->pnl+1); 
      memcpy(mdb->path, afname, mdb->pnl); 
      mdb->path[mdb->pnl] = 0; 
   } else { 
      Mmsg1(&mdb->errmsg, _("Path length is zero. File=%s\n"), afname); 
      Jmsg(jcr, M_FATAL, 0, "%s", mdb->errmsg); 
      mdb->path[0] = 0; 
      mdb->pnl = 0; 
   } 
   Dmsg3(500, "split fname=%s: path=%s file=%s\n", afname, mdb->path, mdb->fname); 
}
void split_path_and_file ( JCR * jcr , BDB * mdb , const char * afname ) { const char * p , * f ; for ( p = f = afname ; * p ; p ++ ) { if ( IsPathSeparator ( * p ) ) { f = p ; } } if ( IsPathSeparator ( * f ) ) { f ++ ; } else { f = p ; } mdb -> fnl = p - f ; if ( mdb -> fnl > 0 ) { mdb -> fname = check_pool_memory_size ( mdb -> fname , mdb -> fnl + 1 ) ; memcpy ( mdb -> fname , f , mdb -> fnl ) ; mdb -> fname [ mdb -> fnl ] = 0 ; } else { mdb -> fname [ 0 ] = 0 ; mdb -> fnl = 0 ; } mdb -> pnl = f - afname ; if ( mdb -> pnl > 0 ) { mdb -> path = check_pool_memory_size ( mdb -> path , mdb -> pnl + 1 ) ; memcpy ( mdb -> path , afname , mdb -> pnl ) ; mdb -> path [ mdb -> pnl ] = 0 ; } else { Mmsg1 ( & mdb -> errmsg , _ ( " \n " ) , afname ) ; Jmsg ( jcr , M_FATAL , 0 , " " , mdb -> errmsg ) ; mdb -> path [ 0 ] = 0 ; mdb -> pnl = 0 ; } Dmsg3 ( 500 , " \n " , afname , mdb -> path , mdb -> fname ) ; }
Given a full filename, split it into its path
  and filename parts.
Given a full filename split it into its path and filename parts .
/* Find path without the filename. 
    * I.e. everything after the last / is a "filename". 
    * OK, maybe it is a directory name, but we treat it like 
    * a filename. If we don't find a / then the whole name 
    * must be a path name (e.g. c:). 
    */ /* set pos of last slash */ /* did we find a slash? */ /* yes, point to filename */ /* no, whole thing must be path name */ /* If filename doesn't exist (i.e. root directory), we 
    * simply create a blank name consisting of a single 
    * space. This makes handling zero length filenames 
    * easier. 
    */ /* copy filename */