BurntSushi / walkdir

Rust library for walking directories recursively.
The Unlicense
1.21k stars 106 forks source link

Different file listing with different OS #178

Closed tiago-ssantos closed 1 year ago

tiago-ssantos commented 1 year ago

When executing a simple example:

use walkdir::WalkDir;

fn main() {
    for entry in WalkDir::new("./files")          
    {
        println!("{}", entry.unwrap().path().display());
    }
}

with the files: image

in Windows and Ubuntu results in:

./files
./files\file1.parquet
./files\file3.parquet

but in macOs Ventura:

./files
./files/file3.parquet
./files/file1.parquet

There a specific parameter to impose a sort, but out of the box should the order by the same, independently of the OS?

BurntSushi commented 1 year ago

should the order by the same, independently of the OS?

Certainly not. The OS determines the order. On Linux at least, the order is unspecified.

If there were some guarantee about ordering, it would definitely be in the docs. But there isn't one. You aren't even guaranteed that subsequent runs on the same OS will produce the same order.