Skip to content

Commit cb6968f

Browse files
authored
Create copyndk.py
1 parent 4667cc0 commit cb6968f

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

copyndk.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import shutil
2+
import os
3+
import sys
4+
5+
def copy_files_and_dirs(source_dir, target_dir):
6+
"""
7+
Copy all files and directories from the source directory to the target directory.
8+
Existing files in the target directory will be overwritten.
9+
10+
Args:
11+
- source_dir: The path to the source directory.
12+
- target_dir: The path to the target directory.
13+
"""
14+
if not os.path.isdir(source_dir):
15+
print(f"The source directory does not exist: {source_dir}")
16+
return
17+
18+
if not os.path.exists(target_dir):
19+
os.makedirs(target_dir, exist_ok=True)
20+
21+
for item in os.listdir(source_dir):
22+
source_path = os.path.join(source_dir, item)
23+
target_path = os.path.join(target_dir, item)
24+
25+
if os.path.isdir(source_path):
26+
# If the item is a directory, recursively copy the directory.
27+
shutil.copytree(source_path, target_path, dirs_exist_ok=True)
28+
print(f"Copied directory {source_path} to {target_path}")
29+
elif os.path.isfile(source_path):
30+
# If the item is a file, copy the file.
31+
shutil.copy2(source_path, target_path)
32+
print(f"Copied file {source_path} to {target_path}")
33+
34+
if __name__ == "__main__":
35+
if len(sys.argv) != 3:
36+
print("Usage: python copy_files.py <source_directory> <target_directory>")
37+
else:
38+
source_directory = sys.argv[1]
39+
target_directory = sys.argv[2]
40+
copy_files_and_dirs(source_directory + "/bin", target_directory + "/bin")
41+
copy_files_and_dirs(source_directory + "/lib/clang", target_directory + "/lib/clang")
42+

0 commit comments

Comments
 (0)