src/strutil.c
/* Get directory path from input filepath (with trailing '/' character) */
Get directory path from input filepath (with trailing '/' character)
Get directory path from input filepath ( with trailing ' / ' character )
char* directoryPath(char* filePath)
{
	int len = strlen(filePath);
	int i;
	int last;
	for (i = len - 1; i >= 0; i--)
	{
		if (filePath[i] == '/')
		{
			last = i;
			break;
		}
	}
	if (i < 0)
		return strdup("./");
	char* str = (char*) malloc(last + 2);
	str[last + 1] = '\0';
	for (i = 0; i <= last; i++)
		str[i] = filePath[i];
	return str;
}
char * directoryPath ( char * filePath ) { int len = strlen ( filePath ) ; int i ; int last ; for ( i = len - 1 ; i >= 0 ; i -- ) { if ( filePath [ i ] == ' ' ) { last = i ; break ; } } if ( i < 0 ) return strdup ( " " ) ; char * str = ( char * ) malloc ( last + 2 ) ; str [ last + 1 ] = ' \0 ' ; for ( i = 0 ; i <= last ; i ++ ) str [ i ] = filePath [ i ] ; return str ; }
Get directory path from input filepath (with trailing '/' character)
Get directory path from input filepath ( with trailing ' / ' character )
// Find ending '/'