On Sat, 20 Dec 2003 17:47:20, Timo Sirainen wrote:
On Dec 20, 2003, at 2:20 PM, Jeroen van Disseldorp wrote:
On Saturday 20 December 2003 04:40, Timo Sirainen wrote:
If I did add special check for ".imap", it would mean that you couldn't create a root folder called "imap" which I think some people might actually do.
I understand. However, making a simple check for being a file or directory wouldn't harm anyone. As .subscriptions, .customflags and .imap* are all files, interpreting them as folders would generate errors anyhow. If .imap* is somehow renamed to .whatever or dovecot-whatever, the check would still hold as files would never be interpreted as mail folders.
It would hurt performance with very little gain. Now I can just do it all with opendir() and readdir() which is usually 2-3 syscalls. If I wanted to know if each entry is file or directory, I'd have to call stat() for each entry. This could be done for those few special cases I guess, but I wouldn't add it for everything..
Modern filesystems return more info from readdir() than just the filename. Check out the d_type field of the direct struct. If it's DT_REG it's a file; it it's DT_DIR it's a directory; if it's DT_UNKNOWN the file system doesn't support it and you have to do a stat().
Mike.