| 1238 | } |
| 1239 | |
| 1240 | U32 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 | |
| 1270 | U32 KProcess::symlinkat(BString target, FD dirfd, BString linkpath) { |
| 1271 | BString currentDirectory; |
no test coverage detected