mirror of
https://github.com/Tencent/MMKV.git
synced 2026-10-17 04:30:56 +08:00
1717fda355
做了以下几处改动: 1.使用了 os.path.join() 拼接路径,确保跨平台兼容性 2.使用了 subprocess.run() 替代 os.system(),避免被包含特殊字符的路径进行注入攻击
18 lines
641 B
Python
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)
|