24 November 2015



There is no guarantee that the name strings in the resulting array
will appear in any specific order; they are not, in particular,
guaranteed to appear in alphabetical order.



在Windows系统上,文件系统的实现类是WinNTFileSystem,获取目录内容最终是通过本地方法WinNTFileSystem.list(File f)实现的(参见这里)。其中在搜索目录内容时,是通过FindFirstFileW方法和FindNextFileW方法完成的(他们是FindFirstFile方法和FindNextFile方法的Unicode版本。


This function uses the same search filters that were used to create the search handle passed in the hFindFile parameter. For additional information, see FindFirstFile and FindFirstFileEx.

The order in which the search returns the files, such as alphabetical order, is not guaranteed, and is dependent on the file system. If the data must be sorted, the application must do the ordering after obtaining all the results.

**Note** In rare cases or on a heavily loaded system, file attribute information on NTFS file systems may not be current at the time this function is called. To be assured of getting the current NTFS file system file attributes, call the GetFileInformationByHandle function.

The order in which this function returns the file names is dependent on the file system type. With the NTFS file system and CDFS file systems, the names are usually returned in alphabetical order. With FAT file systems, the names are usually returned in the order the files were written to the disk, which may or may not be in alphabetical order. However, as stated previously, these behaviors are not guaranteed.



在Linux系统上,FileSystem的实现类是UnixFileSystem,获取目录内容最终是通过本地方法UnixFileSystem.list(File f)实现的(参见这里)。其中,在获取目录项的时候,是通过标准库函数readdir_r来实现的。