MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / symlinkInDirectory

Function symlinkInDirectory

source/kernel/kprocess.cpp:1240–1268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1238}
1239
1240U32 symlinkInDirectory(BString currentDirectory, BString target, BString linkpath) {
1241 std::shared_ptr<FsNode> node;
1242
1243 node = Fs::getNodeFromLocalPath(currentDirectory, linkpath, false);
1244 if (node) {
1245 return -K_EEXIST;
1246 }
1247 BString fullPath = Fs::getFullPath(currentDirectory, linkpath);
1248 BString parentPath = Fs::getParentPath(fullPath);
1249 std::shared_ptr<FsNode> parentNode = Fs::getNodeFromLocalPath(B(""), parentPath, true);
1250
1251 if (!parentNode) {
1252 return -K_ENOENT;
1253 }
1254 node = Fs::addFileNode(fullPath, target, Fs::getNativePathFromParentAndLocalFilename(parentNode, Fs::getFileNameFromPath(linkpath))+EXT_LINK, false, parentNode);
1255
1256 if (!node->canWrite()) {
1257 node->removeNodeFromParent();
1258 return -K_EACCES;
1259 }
1260 FsOpenNode* openNode = node->open( K_O_WRONLY|K_O_CREAT);
1261 if (!openNode) {
1262 node->removeNodeFromParent();
1263 return -K_EIO;
1264 }
1265 openNode->writeNative((U8*)target.c_str(), (U32)target.length());
1266 openNode->close();
1267 return 0;
1268}
1269
1270U32 KProcess::symlinkat(BString target, FD dirfd, BString linkpath) {
1271 BString currentDirectory;

Callers 2

symlinkatMethod · 0.85
symlinkMethod · 0.85

Calls 8

BFunction · 0.85
removeNodeFromParentMethod · 0.80
openMethod · 0.65
closeMethod · 0.65
canWriteMethod · 0.45
writeNativeMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected