示例#1
0
/*
 *  Check to see if source is a parent of the destination.
 *  If it is, issue alert & return TRUE; otherwise just return FALSE.
 *  Must assume that src and dst paths both end with "\*.*".
 */
static WORD source_is_parent(BYTE *psrc_path, FNODE *pflist, BYTE *pdst_path)
{
    BYTE *tsrc, *tdst;
    WORD same;
    FNODE *pf;
    BYTE srcpth[MAXPATHLEN];
    BYTE dstpth[MAXPATHLEN];

    if (psrc_path[0] != pdst_path[0])   /* check drives */
        return FALSE;

    tsrc = srcpth;
    tdst = dstpth;
    same = TRUE;
    do
    {
        /* new copies */
        strcpy(srcpth, psrc_path);
        strcpy(dstpth, pdst_path);

        /* get next paths */
        tsrc = ret_path(tsrc);
        tdst = ret_path(tdst);
        if ( strcmp(tsrc, "*.*") )
        {
            if ( strcmp(tdst, "*.*") )
                same = strcmp(tdst, tsrc);
            else
                same = FALSE;
        }
        else
        {
            /* check to same level */
            if ( !strcmp(tdst, "*.*") )
                same = FALSE;
            else
            {
                /* walk file list */
                for (pf = pflist; pf; pf = pf->f_next)
                {
                    /* exit if same subdir  */
                    if ( (pf->f_obid != NIL) &&
                        (G.g_screen[pf->f_obid].ob_state & SELECTED) &&
                        (pf->f_attr & F_SUBDIR) &&
                        (!strcmp(pf->f_name, tdst)) )
                    {
                        /* INVALID      */
                        fun_alert(1, STBADCOP);
                        return TRUE;
                    }
                }
                same = FALSE;   /* ALL OK */
            }
        }
    } while(same);

    return FALSE;
}
std::string get_path_jobdata(

  const char *jobid,
  const char *basepath)

  {
  std::string ret_path("");
  long        use_jobs_subdirs = FALSE;

  if ((jobid == NULL) || (basepath == NULL))
    return(ret_path);

  ret_path = basepath;

  // get use_jobs_subdirs value if set 
  get_svr_attr_l(SRV_ATR_use_jobs_subdirs, &use_jobs_subdirs);

  // if we are using divided subdirectories in server_priv/{jobs,arrays}
  //  then adjust path
  if ((use_jobs_subdirs == TRUE) && isdigit(*jobid))
    {
    char *p = (char *)jobid + 1;

    // point p to the first non-digit in string
    while (isdigit(*p))
      p++;

    // move back 1 char to the last digit of the job id
    p--;

    // append the last digit of the numeric part of the job id on the string
    ret_path.push_back(*p);

    // append slash
    ret_path.push_back('/');
    }

  return(ret_path);
  }