mirror of
https://github.com/dw-0/kiauh.git
synced 2026-02-03 16:07:44 +05:00
docs(fs_utils): add the documentation for create_symlink (#768)
This commit is contained in:
@@ -47,7 +47,16 @@ def check_file_exist(file_path: Path, sudo=False) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def create_symlink(source: Path, target: Path, sudo=False) -> None:
|
def create_symlink(source: Path, target: Path, sudo=False) -> None:
|
||||||
|
"""
|
||||||
|
Helper function to create a symlink from source to target
|
||||||
|
If the target file exists, it will be overwritten. |
|
||||||
|
:param source: the source file/directory
|
||||||
|
:param target: the target file/directory
|
||||||
|
:param sudo: use sudo if required
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
|
# -f forcibly creates/overwrites the symlink
|
||||||
cmd = ["ln", "-sf", source.as_posix(), target.as_posix()]
|
cmd = ["ln", "-sf", source.as_posix(), target.as_posix()]
|
||||||
if sudo:
|
if sudo:
|
||||||
cmd.insert(0, "sudo")
|
cmd.insert(0, "sudo")
|
||||||
|
|||||||
Reference in New Issue
Block a user