c-md/srcs/utils/string/extract_file_ext.c.md
2026-01-12 16:22:13 +01:00

603 B

extract_file_ext.c

Get the file extension from a given file path.


Includes

#include <string.h>

#include "utils.h"

Function Description

extract_file_ext

Get the file extension from a given file path.

Parameter

  • path: The file path string.

Return Value

Returns a pointer to the file extension within the path string, or NULL if no extension is found.

Implementation

const char *
extract_file_ext(const char *path)
{
	const char	*dot;

	dot = strrchr(path, '.');
	if (NULL == dot || dot == path)
		return (NULL);
	return (dot + 1);
}