35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
# You are free to use and/or change this code for
|
|
# your own needs.
|
|
|
|
# Original code (c)2018 Jan Lerking
|
|
# Program to convert C-header (*.h) files to nasm include files (*.inc),
|
|
# for direct usage in assembly programming using nasm/yasm.
|
|
|
|
import os
|
|
import sys
|
|
from h2inc_parser import parseline, parseparsed
|
|
import h2inc_gui
|
|
|
|
cnt = 0
|
|
|
|
def sourcedir_filecnt(sourcedir):
|
|
### Return the number of files, ending with '.h', in sourcedir - including subdirectories ###
|
|
cnt = 0
|
|
for folderName, subfolders, files in os.walk(sourcedir):
|
|
for file in files:
|
|
if file.lower().endswith('.h'):
|
|
cnt = cnt+1
|
|
return cnt
|
|
|
|
def sourcedir_foldercnt(sourcedir):
|
|
### Return the number of folders, if it contains '*.h' files, in sourcedir - including subdirectories ###
|
|
global cnt
|
|
for folderName, subfolders, files in os.walk(sourcedir):
|
|
if subfolders:
|
|
for subfolder in subfolders:
|
|
sourcedir_foldercnt(subfolder)
|
|
tempf = [file for file in files if file.lower().endswith('.h')]
|
|
if tempf:
|
|
cnt = cnt+1
|
|
print(folderName)
|
|
return cnt |