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

Function ResolveParent

Kernel/src/fs/filesystem.cpp:215–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213 }
214
215 FsNode* ResolveParent(const char* path, const char* workingDir){
216 char* pathCopy = (char*)kmalloc(strlen(path) + 1);
217 strcpy(pathCopy, path);
218
219 if(pathCopy[strlen(pathCopy) - 1] == '/'){ // Remove trailing slash
220 pathCopy[strlen(pathCopy) - 1] = 0;
221 }
222
223 char* dirPath = strrchr(pathCopy, '/');
224
225 FsNode* parentDirectory = nullptr;
226
227 if(dirPath == nullptr){
228 parentDirectory = fs::ResolvePath(workingDir);
229 } else {
230 *(dirPath - 1) = 0; // Cut off the directory name from the path copy
231 parentDirectory = fs::ResolvePath(pathCopy, workingDir);
232 }
233
234 kfree(pathCopy);
235 return parentDirectory;
236 }
237
238 FsNode* ResolveParent(const char* path, FsNode* workingDir){
239 char* pathCopy = (char*)kmalloc(strlen(path) + 1);

Callers 7

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

Calls 6

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

Tested by

no test coverage detected