2024-09-04 08:20:10 -04:00
|
|
|
/-
|
|
|
|
Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved.
|
|
|
|
Released under Apache 2.0 license.
|
|
|
|
Authors: Joseph Tooby-Smith
|
|
|
|
-/
|
2025-01-22 10:32:39 +00:00
|
|
|
import HepLean.Meta.TODO.Basic
|
2024-09-04 08:20:10 -04:00
|
|
|
/-!
|
|
|
|
|
|
|
|
## Getting an array of all file paths in HepLean.
|
|
|
|
|
|
|
|
-/
|
|
|
|
|
2025-02-02 03:17:17 +08:00
|
|
|
open System
|
2024-09-04 08:20:10 -04:00
|
|
|
|
2025-01-24 14:05:54 +00:00
|
|
|
TODO "Make this definition more functional in style. In other words, remove the for loop."
|
2024-09-04 08:20:10 -04:00
|
|
|
|
2024-09-04 08:33:00 -04:00
|
|
|
/-- The recursive function underlying `allFilePaths`. -/
|
|
|
|
partial def allFilePaths.go (prev : Array FilePath)
|
2025-01-05 16:00:30 +00:00
|
|
|
(root : String) (path : FilePath) : IO (Array FilePath) := do
|
2024-09-04 08:20:10 -04:00
|
|
|
let mut r := prev
|
|
|
|
for entry in ← path.readDir do
|
|
|
|
if ← entry.path.isDir then
|
2025-01-05 16:00:30 +00:00
|
|
|
r ← go r (root ++ "/" ++ entry.fileName) entry.path
|
2024-09-04 08:20:10 -04:00
|
|
|
else
|
2025-01-05 16:00:30 +00:00
|
|
|
r := r.push (root ++ "/" ++ entry.fileName)
|
2024-09-04 08:20:10 -04:00
|
|
|
pure r
|
2024-09-04 08:33:00 -04:00
|
|
|
|
|
|
|
/-- Gets an array of all file paths in `HepLean`. -/
|
|
|
|
partial def allFilePaths : IO (Array FilePath) := do
|
2025-01-05 16:00:30 +00:00
|
|
|
allFilePaths.go (#[] : Array FilePath) "./HepLean" ("./HepLean" : FilePath)
|