问题描述
我收到使用执行opendir / readdir的一个类似Linux系统中的文件列表。看来,目录项的文件名的字母顺序返回。不过,我没有看到关于此订单所保证的手册页事情。
I'm getting a list of files on a linux-like system using opendir/readdir. It appears that the directory entries are returned in alphabetical order of file name. However, I don't see anything in the man pages about this order being guaranteed.
谁能告诉我是否不READDIR guarrantees订单?
Can anyone tell me whether or not readdir guarrantees an order?
推荐答案
的 READDIR
方法不保证任何顺序。如果你想确保他们按字母顺序排序,你需要这样做自己。
The readdir
method doesn't guarantee any ordering. If you want to ensure they are sorted alphabetically you'll need to do so yourself.
请注意:我搜索了一下对最终文件说这样的话。我来最接近的是下面的链接
Note: I searched for a bit for definitive documentation saying this is the case. The closest I came is the following link
这决不是明确的,但它确实给该命令的很好的概述,它的历史以及它的实现通常是遍历顺序。
It's by no means definitive but it does give a nice overview of the command, it's history and how it's implementation is typically traversal order.
这篇关于是否READDIR()保证订单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!