Files
MMKV/Script/formatCode.py
xiezheng-XD 1717fda355 Update formatCode.py
做了以下几处改动:
1.使用了 os.path.join() 拼接路径,确保跨平台兼容性
2.使用了 subprocess.run() 替代 os.system(),避免被包含特殊字符的路径进行注入攻击
2023-08-31 01:07:28 +08:00

18 lines
641 B
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import os.path
import subprocess
path = os.getcwd()
excluded_directories = ["pybind11", "/openssl", "/zlib", "/build/generated/", "cmake-build-debug/", "cmake-build-release", "CMakeFiles"]
for root, dirs, files in os.walk(path):
if any(excluded_dir in root for excluded_dir in excluded_directories):
continue
for name in files:
if name.endswith((".h", ".m", ".mm", ".hpp", ".cpp", ".java")):
localpath = os.path.join(root, name)
print(localpath)
subprocess.run(["clang-format", "-i", localpath, "-style=File"], check=True)