4 ms·
I'm missing something. What difference do you see between "accessing files by name" and "searching by filename"?
by ngrilly 9y ago
I'm missing something. What difference do you see between "accessing files by name" and "searching by filename"?
- the8472 9y agof = open("/path/to/file"); // do something with file vs. d = opendir("path/to") while((dent = readdir(d)) != NULL) { if(!dent.name.startsWith("file")) continue; // do something with first matched entry } The former is O(log n) on ext4, O(n) on older filesystems that use flat lists. The latter is always O(n)
- ngrilly 9y agoUnderstood. Thanks ;-)