libc: Add libgen.h
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-03-28 19:47:47 +02:00
parent d00ca0d3ed
commit df10544e84
Signed by: asleepymoon
GPG Key ID: B8A7D06E42258954
3 changed files with 69 additions and 40 deletions

23
libc/include/libgen.h Normal file
View File

@ -0,0 +1,23 @@
/* libgen.h: Path parsing functions. */
#ifndef _LIBGEN_H
#define _LIBGEN_H
// These functions are implemented in libluna (CPath.h)
#ifdef __cplusplus
extern "C"
{
#endif
/* Returns path's base name. Will modify path. */
char* basename(char* path);
/* Returns path's parent directory. Will modify path. */
char* dirname(char* path);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,4 +1,7 @@
#pragma once
extern "C"
{
char* basename(char*);
char* dirname(char*);
}

View File

@ -3,6 +3,8 @@
static char dot[] = ".";
extern "C"
{
char* basename(char* path)
{
// If path is NULL, or the string's length is 0, return .
@ -45,3 +47,4 @@ char* dirname(char* path)
*(end + 1) = 0;
return path;
}
}