stats.c
char *cmd_path(char *cmd, char *path)
{
	unsigned int i, bi;
	struct stat st;
	char *buf;

	if (!cmd || !path)
		return (NULL);
	if (!path[0])
		return (NULL);
/*  allocate buffer for both strings, plus NULL byte and '/' char */
	buf = malloc(sizeof(char) * (_strlen(cmd) + _strlen(path) + 2));
	if (!buf)
		return (NULL);
/* put path directory into buffer */
	for (bi = 0; path[bi]; bi++)
		buf[bi] = path[bi];
/* start buffer index at end of directory name, replacing NULL byte with '/' */
	if (cmd[0] != '/')
		buf[bi++] = '/';
/* write the arguments into the buffer to get full path */
	for (i = 0; cmd[i]; i++, bi++)
		buf[bi] = cmd[i];
	buf[bi] = 00;
	if (stat(buf, &st) == 0)
		return (buf);
	free(buf);
	return (NULL);
}
/**
 * cmd_path - appends the cmd string to the given path directory if found there
 * @cmd: first string of command
 * @path: single path directory string to test
 * Return: string starting with path and ending with the cmd if found there,
 * else NULL
 */
appends the cmd string to the given path directory if found there
@cmd: first string of command
@path: single path directory string to test
Return: string starting with path and ending with the cmd if found there,
else NULL
appends the cmd string to the given path directory if found there @cmd : first string of command @path : single path directory string to test Return : string starting with path and ending with the cmd if found there else NULL
char *cmd_path(char *cmd, char *path)
{
	unsigned int i, bi;
	struct stat st;
	char *buf;
	if (!cmd || !path)
		return (NULL);
	if (!path[0])
		return (NULL);
	buf = malloc(sizeof(char) * (_strlen(cmd) + _strlen(path) + 2));
	if (!buf)
		return (NULL);
	for (bi = 0; path[bi]; bi++)
		buf[bi] = path[bi];
	if (cmd[0] != '/')
		buf[bi++] = '/';
	for (i = 0; cmd[i]; i++, bi++)
		buf[bi] = cmd[i];
	buf[bi] = 00;
	if (stat(buf, &st) == 0)
		return (buf);
	free(buf);
	return (NULL);
}
char * cmd_path ( char * cmd , char * path ) { unsigned int i , bi ; struct stat st ; char * buf ; if ( ! cmd || ! path ) return ( NULL ) ; if ( ! path [ 0 ] ) return ( NULL ) ; buf = malloc ( sizeof ( char ) * ( _strlen ( cmd ) + _strlen ( path ) + 2 ) ) ; if ( ! buf ) return ( NULL ) ; for ( bi = 0 ; path [ bi ] ; bi ++ ) buf [ bi ] = path [ bi ] ; if ( cmd [ 0 ] != ' ' ) buf [ bi ++ ] = ' ' ; for ( i = 0 ; cmd [ i ] ; i ++ , bi ++ ) buf [ bi ] = cmd [ i ] ; buf [ bi ] = 00 ; if ( stat ( buf , & st ) == 0 ) return ( buf ) ; free ( buf ) ; return ( NULL ) ; }
cmd_path - appends the cmd string to the given path directory if found there
 @cmd: first string of command
 @path: single path directory string to test
 Return: string starting with path and ending with the cmd if found there,
 else NULL
cmd_path - appends the cmd string to the given path directory if found there @cmd : first string of command @path : single path directory string to test Return : string starting with path and ending with the cmd if found there else NULL
/*  allocate buffer for both strings, plus NULL byte and '/' char */ /* put path directory into buffer */ /* start buffer index at end of directory name, replacing NULL byte with '/' */ /* write the arguments into the buffer to get full path */