libite/copyfile.c
/* Tests if dst is a directory, if so, reallocates dst and appends src filename returning 1 */
Tests if dst is a directory, if so, reallocates dst and appends src filename returning 1
Tests if dst is a directory if so reallocates dst and appends src filename returning 1
static int adjust_target(char *src, char **dst)
{
	int isdir = 0;
	if (fisdir(*dst)) {
		int slash = 0;
		char *tmp, *ptr = strrchr(src, '/');
		if (!ptr)
			ptr = src;
		else
			ptr++;
		tmp = malloc(strlen(*dst) + strlen(ptr) + 2);
		if (!tmp) {
			errno = EISDIR;
			return 0;
		}
		isdir = 1;	
		slash = fisslashdir(*dst);
		sprintf(tmp, "%s%s%s", *dst, slash ? "" : "/", ptr);
		*dst = tmp;
	}
	return isdir;
}
static int adjust_target ( char * src , char * * dst ) { int isdir = 0 ; if ( fisdir ( * dst ) ) { int slash = 0 ; char * tmp , * ptr = strrchr ( src , ' ' ) ; if ( ! ptr ) ptr = src ; else ptr ++ ; tmp = malloc ( strlen ( * dst ) + strlen ( ptr ) + 2 ) ; if ( ! tmp ) { errno = EISDIR ; return 0 ; } isdir = 1 ; slash = fisslashdir ( * dst ) ; sprintf ( tmp , " " , * dst , slash ? " " : " " , ptr ) ; * dst = tmp ; } return isdir ; }
Tests if dst is a directory, if so, reallocates dst and appends src filename returning 1
Tests if dst is a directory if so reallocates dst and appends src filename returning 1
/* Free dst before exit! */