Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • Shorter code is not a virtue. A code, that requires a special note, is a vice. AFAIK, the order of . and .. is not guaranteed in all systems Commented Aug 16, 2025 at 11:43
  • @YourCommonSense, "Shorter code is not a virtue": true. But simpler code is. Moreover, the order has nothing to do with this. Their existence only is required (and guaranteed). If the directory has more than 2 entries it is not empty. Nobody said anything about order. This code makes sure that, no matter what happens, closedir is called. And can very easily be modified to return error information. Commented Aug 16, 2025 at 13:24