Created
April 23, 2024 14:18
-
-
Save delasy/9231cbd0f2ae90368d54c70e9c6604e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn calcFileLines (filePath: str) int { | |
content := fs_readFileSync(filePath).str() | |
return content.lines().len | |
} | |
fn traverse (path: str) str[] { | |
entries := fs_scandirSync(path) | |
mut files: str[] | |
loop i := entries.len - 1; i >= 0; i-- { | |
entry := path + path_SEP + entries[i] | |
if fs_isFileSync(entry) { | |
files.push(entry) | |
} else { | |
f := traverse(entry) | |
files.merge(f) | |
} | |
} | |
return files | |
} | |
main { | |
files := traverse("./folder") | |
mut mostLines := 0 | |
mut file := "" | |
loop i := files.len - 1; i >= 0; i-- { | |
lines := calcFileLines(files[i]) | |
if lines > mostLines { | |
mostLines = lines | |
file = files[i] | |
} | |
} | |
print(file, mostLines) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment