diff options
| author | YurenHao0426 <blackhao0426@gmail.com> | 2026-01-13 23:50:59 -0600 |
|---|---|---|
| committer | YurenHao0426 <blackhao0426@gmail.com> | 2026-01-13 23:50:59 -0600 |
| commit | 00cf667cee7ffacb144d5805fc7e0ef443f3583a (patch) | |
| tree | 77d20a3adaecf96bf3aff0612bdd3b5fa1a7dc7e /files/data_io/utils/file_utils.py | |
| parent | c53c04aa1d6ff75cb478a9498c370baa929c74b6 (diff) | |
| parent | cd99d6b874d9d09b3bb87b8485cc787885af71f1 (diff) | |
Merge master into main
Diffstat (limited to 'files/data_io/utils/file_utils.py')
| -rw-r--r-- | files/data_io/utils/file_utils.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/files/data_io/utils/file_utils.py b/files/data_io/utils/file_utils.py new file mode 100644 index 0000000..0a1e846 --- /dev/null +++ b/files/data_io/utils/file_utils.py @@ -0,0 +1,15 @@ +import os + +def ensure_dir(path: str): + """Ensure that a directory exists.""" + if not os.path.exists(path): + os.makedirs(path) + +def list_files(root: str, suffix: str): + """Recursively list files ending with suffix.""" + matches = [] + for dirpath, _, filenames in os.walk(root): + for f in filenames: + if f.endswith(suffix): + matches.append(os.path.join(dirpath, f)) + return matches |
