librnr/path.c
char *NewJoinedPath(const char *sPath1, const char *sPath2)
{
  char   *p1 = NULL;
  char   *p2 = NULL;
  char   *pj = NULL;

  // canonicalize path 2
  if( (p2 = NewSearchPathCanonicalized(sPath2)) == NULL )
  {
    LOGERROR("NewSearchPathCanonicalized(\"%s\") failed.", sPath2);
  }

  // if the second path is an absolute path, cannot join
  else if( PathIsAbsolute(p2) )
  {
    return p2;
  }

  // canonicalize path 1
  else if( (p1 = NewSearchPathCanonicalized(sPath1)) == NULL )
  {
    LOGERROR("NewSearchPathCanonicalized(\"%s\") failed.", sPath1);
  }

  // join
  else
  {
    pj = NEWSTR(strlen(p1)+strlen(DIR_SEP_STR)+strlen(p2));
    sprintf(pj, "%s%s%s", p1, DIR_SEP_STR, p2);
  }

  delete(p1);
  delete(p2);

  return pj;
}
/*!
 * \brief Join two file paths.
 *
 * The paths are expanded and canonicalized. The paths do not have to exist.
 * If the second, appended path is an absolute path, then the joined path is
 * the second path.
 *
 * \param  sPath1   Front absolute/relative path.
 * \param  sPath2   Appended, back end path.
 *
 * \return
 * On success, an allocated, canonical joined path name is returned.\n
 * On failure, NULL is returned.
 */
\brief Join two file paths.
The paths are expanded and canonicalized. The paths do not have to exist.
If the second, appended path is an absolute path, then the joined path is
the second path.

\param  sPath1   Front absolute/relative path.
\param  sPath2   Appended, back end path.

\return
On success, an allocated, canonical joined path name is returned.\n
On failure, NULL is returned.
\ brief Join two file paths . The paths are expanded and canonicalized . The paths do not have to exist . If the second appended path is an absolute path then the joined path is the second path . \ param sPath1 Front absolute / relative path . \ param sPath2 Appended back end path . \ return On success an allocated canonical joined path name is returned . \ n On failure NULL is returned .
char *NewJoinedPath(const char *sPath1, const char *sPath2)
{
  char   *p1 = NULL;
  char   *p2 = NULL;
  char   *pj = NULL;
  if( (p2 = NewSearchPathCanonicalized(sPath2)) == NULL )
  {
    LOGERROR("NewSearchPathCanonicalized(\"%s\") failed.", sPath2);
  }
  else if( PathIsAbsolute(p2) )
  {
    return p2;
  }
  else if( (p1 = NewSearchPathCanonicalized(sPath1)) == NULL )
  {
    LOGERROR("NewSearchPathCanonicalized(\"%s\") failed.", sPath1);
  }
  else
  {
    pj = NEWSTR(strlen(p1)+strlen(DIR_SEP_STR)+strlen(p2));
    sprintf(pj, "%s%s%s", p1, DIR_SEP_STR, p2);
  }
  delete(p1);
  delete(p2);
  return pj;
}
char * NewJoinedPath ( const char * sPath1 , const char * sPath2 ) { char * p1 = NULL ; char * p2 = NULL ; char * pj = NULL ; if ( ( p2 = NewSearchPathCanonicalized ( sPath2 ) ) == NULL ) { LOGERROR ( " \" \" " , sPath2 ) ; } else if ( PathIsAbsolute ( p2 ) ) { return p2 ; } else if ( ( p1 = NewSearchPathCanonicalized ( sPath1 ) ) == NULL ) { LOGERROR ( " \" \" " , sPath1 ) ; } else { pj = NEWSTR ( strlen ( p1 ) + strlen ( DIR_SEP_STR ) + strlen ( p2 ) ) ; sprintf ( pj , " " , p1 , DIR_SEP_STR , p2 ) ; } delete ( p1 ) ; delete ( p2 ) ; return pj ; }
\brief Join two file paths.
\ brief Join two file paths .
// canonicalize path 2 // if the second path is an absolute path, cannot join // canonicalize path 1 // join