25 lines
694 B
Python
Executable File
25 lines
694 B
Python
Executable File
#!/usr/bin/python3
|
|
|
|
import os
|
|
import sys
|
|
|
|
def find_c_h_files(dirs):
|
|
files = []
|
|
for d in dirs:
|
|
for root, _, filenames in os.walk(d):
|
|
for fname in filenames:
|
|
if fname.endswith('.c') or fname.endswith('.h'):
|
|
files.append(os.path.join(root, fname))
|
|
return sorted(files)
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 2:
|
|
print("Usage: python gen_filelist.py <dir1> [dir2] ...")
|
|
sys.exit(1)
|
|
dirs = sys.argv[1:]
|
|
files = find_c_h_files(dirs)
|
|
with open('filelist.txt', 'w') as f:
|
|
for file in files:
|
|
f.write(file + '\n')
|
|
print(f"Generated filelist.txt with {len(files)} files.")
|