void merge_pathnames( COStream out, boolean just_dir, const char* dpath, const char* npath, const char* tpath ) { /* create a pathname by taking the directory from the first argument, the name from the second, and the extension from the third. */ const char* dname; const char* nname; const char* ntype; const char* p; ntype = pathname_type(npath); if ( is_absolute_pathname(npath) || dpath == NULL || dpath[0] == '\0' ) nname = npath; else { nname = pathname_name_and_type(npath); if ( just_dir ) { cos_puts(out,dpath); if ( cos_prevch(out) != DirDelim ) cos_putch(out,DirDelim); } else { dname = pathname_name_and_type(dpath); for ( p = dpath ; p < dname ; p++ ) cos_putch(out,*p); } } if ( ntype == NULL ) cos_puts(out,nname); else for ( p = nname ; p < ntype ; p++ ) cos_putch(out,*p); p = NULL; if ( tpath != NULL ) { p = pathname_type(tpath); if ( p == NULL && tpath[0] != '\0' && strchr(tpath,DirDelim)==NULL ) p = tpath; } if ( p == NULL ) p = ntype; if ( p != NULL ) { if ( cos_prevch(out) != '.' ) cos_putch(out,'.'); cos_puts(out, p); } }
std::string operator()(const std::string &pathname) { return make_pathname(new_directory, pathname_name(pathname), pathname_type(pathname)); }