MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / BaseName

Function BaseName

Kernel/src/fs/filesystem.cpp:317–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315 }
316
317 char* BaseName(const char* path){
318 char* pathCopy = (char*)kmalloc(strlen(path) + 1);
319 strcpy(pathCopy, path);
320
321 if(pathCopy[strlen(pathCopy) - 1] == '/'){ // Remove trailing slash
322 pathCopy[strlen(pathCopy) - 1] = 0;
323 }
324
325 char* basename = nullptr;
326 char* temp;
327 if((temp = strrchr(pathCopy, '/'))){
328 basename = (char*)kmalloc(strlen(temp) + 1);
329 strcpy(basename, temp);
330
331 kfree(pathCopy);
332 } else {
333 basename = pathCopy;
334 }
335
336 return basename;
337 }
338
339 int Root::ReadDir(DirectoryEntry* dirent, uint32_t index){
340 if (index < fs::volumes->get_length()){

Callers 8

SysExecFunction · 0.85
SysOpenFunction · 0.85
SysLinkFunction · 0.85
SysUnlinkFunction · 0.85
SysMkdirFunction · 0.85
SysRmdirFunction · 0.85
SysRenameFunction · 0.85
RenameFunction · 0.85

Calls 5

kmallocFunction · 0.85
strlenFunction · 0.85
strcpyFunction · 0.85
strrchrFunction · 0.85
kfreeFunction · 0.85

Tested by

no test coverage detected