Jacob Moodynpe: add libgen.h9e05fc73 years agoHistory
24 lines · 404 B · C
RawDownload
#include <libgen.h> char*dirname(char *path){	char *p; 	if(path == nil || path[0] == 0)		return ".";	if(path[0] != 0 && path[0] == '/' && path[1] == 0)		return path;	p = path + strlen(path);	for(p--; p > path+1 && *p == '/'; p--)		*p = 0;	for(p--; p > path && *p != '/'; p--)		;	if(*p == '/' && p == path)		return "/";	if(p == path)		return ".";	if(*p == '/')		*p = 0;	return path;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t