Skip to content

Commit ccd1eec

Browse files
authored
Recreating Directory Structure: The process_directory function calculates the relative path of each PHP file and creates the corresponding subdirectory in the output directory. Adjusting the Obfuscation Function: The obfuscate_php function now creates the target directory if it doesn't exist, ensuring that the directory structure is maintained. With these changes, the script will replicate the directory structure of the input project in the output directory, maintaining the same hierarchy for obfuscated files.
1 parent 7e9ddc7 commit ccd1eec

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

main.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ def obfuscate_php(input_file, obfuscation_options, create_backup, output_directo
3636
logging.info(f"Created backup: {backup_file}")
3737

3838
try:
39+
# Create the directory if it doesn't exist
40+
os.makedirs(output_directory, exist_ok=True)
41+
3942
output_file = os.path.join(output_directory, f"obfuscated_{os.path.basename(input_file)}")
4043
logging.info(f"Obfuscating {input_file}")
4144

@@ -68,7 +71,11 @@ def process_directory(directory, obfuscation_options, exclude_list, create_backu
6871
logging.info(f"Skipping {input_file}: excluded")
6972
continue
7073

71-
file_list.append((input_file, obfuscation_options, create_backup, output_directory))
74+
# Calculate the target directory in the output structure
75+
relative_path = os.path.relpath(root, directory)
76+
target_directory = os.path.join(output_directory, relative_path)
77+
78+
file_list.append((input_file, obfuscation_options, create_backup, target_directory))
7279

7380
progress_bar = tqdm(total=len(file_list), desc="Obfuscating", unit="file")
7481

0 commit comments

Comments
 (0)