Ich habe da mal ein wenig mit gespielt... das geht ja wirklich sauschnell mit Nim!
Momentan sieht das dann so aus:
>getIncludesOfIncludes.exe "c:\Program Files (x86)\AutoIt3\Include\" m:\Temp\IncTest.ini
...
0:WinAPIlangConstants.au3:
3:WinAPILocale.au3:APILocaleConstants.au3|StringConstants.au3|WinAPIInternals.au3
1:WinAPIMem.au3:WinAPIInternals.au3
5:WinAPIMisc.au3:APIMiscConstants.au3|StringConstants.au3|StructureConstants.au3|WinAPIConv.au3|WinAPIMem.au3
8:WinAPIProc.au3:APIProcConstants.au3|Security.au3|SecurityConstants.au3|StringConstants.au3|WinAPICom.au3|WinAPIError.au3|WinAPIHObj.au3|WinAPIShPath.au3
6:WinAPIReg.au3:APIRegConstants.au3|StringConstants.au3|StructureConstants.au3|WinAPICom.au3|WinAPIError.au3|WinAPIMem.au3
6:WinAPIRes.au3:APILocaleConstants.au3|APIResConstants.au3|WinAPIConv.au3|WinAPIError.au3|WinAPIIcons.au3|WinAPIInternals.au3
...
Die kompletten Includes von der Release, Beta und User, sind damit in nur wenigen Sekunden komplett durchsucht.
Warum die Spielerei?
Deshalb:
import os
import strutils
include winim/[inc\shellapi]
proc getIncludesOfIncludes(sPath, sSaveTo: string): int =
var
entireFile, sLine, sIncludesOfIncludes, pattern, match: string = ""
spacer: string = "\n" & repeat("-", 31) & "\n"
iline, fileCount: int = 0
# echo "sPath = (" & $type(sPath) & ") " & sPath
# echo "sSaveTo = (" & $type(sSaveTo) & ") " & sSaveTo
var wPath = newWideCString(sPath, 4096)
if PathFileExistsW(cast[LPCWSTR](wPath)) != TRUE:
echo "File not found!\n===>>> " & sPath
quit(3)
if PathIsDirectoryW(cast[LPCWSTR](wPath)) == FILE_ATTRIBUTE_DIRECTORY:
pattern = r"\*.au3"
discard tryRemoveFile(sSaveTo)
# echo "spath.len = ", spath.len
# echo "sPath & pattern = " & sPath & pattern
for walk in walkFiles(sPath & pattern):
fileCount += 1
# echo "walk (" & $type(walk) & ") = " & walk
entireFile = readFile(walk) # * Hier könnte noch viel Zeit ein-
for line in splitLines(entireFile): # * gespart werden, wenn z.B. nur die
if line.startsWith("#include "): # * ersten 100 Zeilen durchsucht werden.
# echo "line (" & $type(line) & ") = " & line
match = line[10..^2] # ? #include '"< entfernen
var k = 5 # ? x.au3 <<<=== min. 5 Zeichen
while k < len(match): # ? >'".* entfernen
if match[k] == chr(34) or match[k] == chr(39) or match[k] == chr(62):
match = match[0..k - 1]
break
inc(k)
# echo "match (" & $type(match) & ") = " & match
if not contains(sLine, match): # ? include mehrfach deklariert!
if sLine != "": sLine &= "|"
sLine &= match
match = ""
iline += 1
var f = splitFile(walk) # * c:\Program Files...\|Array|.au3
sIncludesOfIncludes &= $iline & ":" & f.name & f.ext & ":" & sLine & "\n"
result += iLine
iline = 0
sLine = ""
echo "----- IncludesOfIncludes -----\n",
"Files: ", fileCount, ", Matches: ", result,"\n",
spacer,
sIncludesOfIncludes
writeFile(sSaveTo, sIncludesOfIncludes)
var usage: string = r"Usage: getIncludesOfIncludes <Filename.au3|Dirname> <SaveAs.ini>\nDirname without trailing backslash!"
if paramCount() == 2:
var
sPath = paramStr(1)
sSaveAs = paramStr(2)
if splitFile(sSaveAs).ext != ".ini":
echo sPath, " ", sSaveAs, "\n", usage
quit(2)
var res = getIncludesOfIncludes(sPath, sSaveAs)
echo "Number of matches: ", res
else:
echo "paramCount() = ", paramCount()
echo usage
# quit(1)
#[ Als Parameter entweder eine Datei oder ein Verzeichnisse übergeben,
und den Daeipfad, unter dem das Ergebnis gespeichert werden soll.
getIncludesOfIncludes(r"m:\Temp\GUICreate.au3", r"m:\Temp\IncludesOfIncludesTest.ini")
getIncludesOfIncludes(r"f:\AutoIt\AutoIt3_MyInclude", r"m:\Temp\IncludesOfIncludesUser.ini")
getIncludesOfIncludes(r"c:\Program Files (x86)\AutoIt3\Include", r"m:\Temp\IncludesOfIncludesProd.ini")
getIncludesOfIncludes(r"c:\Program Files (x86)\AutoIt3\Beta\Include", r"m:\Temp\IncludesOfIncludesBeta.ini")
]#
Alles anzeigen