在 Haxe 的文件夹中查找并列出所有 files/folders
Find and list all files/folders in a folder in Haxe
这个问题和这里的问题大体上是一样的
- How to read all files in a folder from Java?
- How do I list all files of a directory?
- ...
但是有没有办法在 Haxe 的 sys 目标平台上做同样的事情,而不需要通过 sys.io.Process
运行 ls
/ dir
并解析结果?
是的,您可以为此使用 sys.FileSystem.readDirectory(path)
。
Returns the names of all files and directories in the directory specified by path
.
If path
does not denote a valid directory, an exception is thrown.
If path
is null, the result is unspecified.
如果您需要递归地列出文件,Haxe Code Cookbook 中的this article 是一个很好的参考(有一个标题为“递归循环遍历所有目录/文件").
这个问题和这里的问题大体上是一样的
- How to read all files in a folder from Java?
- How do I list all files of a directory?
- ...
但是有没有办法在 Haxe 的 sys 目标平台上做同样的事情,而不需要通过 sys.io.Process
运行 ls
/ dir
并解析结果?
是的,您可以为此使用 sys.FileSystem.readDirectory(path)
。
Returns the names of all files and directories in the directory specified by
path
.If
path
does not denote a valid directory, an exception is thrown.If
path
is null, the result is unspecified.
如果您需要递归地列出文件,Haxe Code Cookbook 中的this article 是一个很好的参考(有一个标题为“递归循环遍历所有目录/文件").