Skip to content

Commit

Permalink
Recreating Directory Structure: The process_directory function calcul…
Browse files Browse the repository at this point in the history
…ates 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.
  • Loading branch information
mnestorov authored May 22, 2024
1 parent 7e9ddc7 commit ccd1eec
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def obfuscate_php(input_file, obfuscation_options, create_backup, output_directo
logging.info(f"Created backup: {backup_file}")

try:
# Create the directory if it doesn't exist
os.makedirs(output_directory, exist_ok=True)

output_file = os.path.join(output_directory, f"obfuscated_{os.path.basename(input_file)}")
logging.info(f"Obfuscating {input_file}")

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

file_list.append((input_file, obfuscation_options, create_backup, output_directory))
# Calculate the target directory in the output structure
relative_path = os.path.relpath(root, directory)
target_directory = os.path.join(output_directory, relative_path)

file_list.append((input_file, obfuscation_options, create_backup, target_directory))

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

Expand Down

0 comments on commit ccd1eec

Please sign in to comment.