-
-
Notifications
You must be signed in to change notification settings - Fork 35
Support creating hard links #301 #310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
408bdff
93c9643
38be3ef
baa9a41
51db31b
80148af
f9c7fdd
9e58f8d
e7b6a3e
1d62994
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,11 +118,50 @@ def pwd(_show=True): | |
| return cwd | ||
|
|
||
|
|
||
| def ln(source, target): | ||
| dirpath = os.path.dirname(target) | ||
| if not os.path.isdir(dirpath): | ||
| mkdir(dirpath) | ||
| os.symlink(source, target) | ||
| def ln(source, target, symbolic): | ||
dxlr8r marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if symbolic: | ||
| dirpath = os.path.dirname(target) | ||
| if not os.path.isdir(dirpath): | ||
| mkdir(dirpath) | ||
| os.symlink(source, target) | ||
| else: | ||
| if not os.path.isdir(target): | ||
| mkdir(target) | ||
| # sync files and directories to source not present in target | ||
| for (wd_source, dirs, files) in os.walk(source): | ||
| wd_target = os.path.normpath( | ||
| os.path.join(target, os.path.relpath(wd_source, source)) | ||
| ) | ||
| for dir in dirs: | ||
| mkdir(os.path.join(wd_target, dir)) | ||
| for file in files: | ||
| file_source = os.path.join(wd_source, file) | ||
| file_target = os.path.join(wd_target, file) | ||
| if not os.path.exists(file_target): | ||
| os.link(file_source, file_target) | ||
|
|
||
| # delete files and record directories from target not present in source | ||
| target_dirs = [] | ||
| for (cwd, dirs, files) in os.walk(target): | ||
| wd_source = os.path.normpath( | ||
| os.path.join(source, os.path.relpath(cwd, target)) | ||
| ) | ||
|
|
||
| for file in files: | ||
| target_file = os.path.join(cwd, file) | ||
| source_file = os.path.join(wd_source, file) | ||
| if not os.path.isfile(source_file): | ||
| rm(target_file) | ||
|
|
||
| for dir in dirs: | ||
| target_dir = os.path.join(cwd, dir) | ||
| source_dir = os.path.join(wd_source, dir) | ||
| if not os.path.isdir(source_dir): | ||
| target_dirs.append(target_dir) | ||
|
|
||
| # delete directories from target not present in source | ||
| for dir in target_dirs: | ||
| rm(dir) | ||
|
||
|
|
||
|
|
||
| def rm(path): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.