Nigel
b07b4f0d38
Problem: As our kernel grows we need more complex datastructures and functions these would come from the standard C/C++ library with normal programs. The kernel is a freestanding programme and has no access to standard libraries. Solution: We build a mini version of the standard C/C++ library which will contain the datastructures and functions we want. This library can then be statically linked into our kernel binary. Making it a statically linked library also gives more structure to the project. Keeping these random functions and datastructures in the kernel just clutters the kernel source code with less relevant source code.
24 lines
357 B
C++
24 lines
357 B
C++
//
|
|
// Created by nigel on 19/02/23.
|
|
//
|
|
#include "Path.h"
|
|
|
|
Path::Path(String path)
|
|
: path(path)
|
|
{
|
|
|
|
}
|
|
|
|
StringView Path::getbasename()
|
|
{
|
|
unsigned int path_length = path.length();
|
|
int i = path_length;
|
|
while (path[i] != '/')
|
|
i--;
|
|
|
|
return {path,static_cast<unsigned int>(i +1), path_length};
|
|
}
|
|
|
|
char* Path::str() {
|
|
return path.str();
|
|
} |