X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=mbox.c;h=bafb7f3db0f6a55b2770a632eaf5d6d8a7073200;hb=2f928128cac1c0bc2ce2465671e5abe2a9671d28;hp=3d1a31cc6571a993e351724ab6ee8b0576450660;hpb=25bf57d598476b329536fa3f748cc0c529fef6bd;p=apps%2Fmadmutt.git diff --git a/mbox.c b/mbox.c index 3d1a31c..bafb7f3 100644 --- a/mbox.c +++ b/mbox.c @@ -1155,16 +1155,15 @@ int mbox_check_empty (const char *path) return ((st.st_size == 0)); } -int mbox_is_magic (const char* path) { - struct stat st; - int magic = 0; +int mbox_is_magic (const char* path, struct stat* st) { + int magic = -1; FILE* f; char tmp[_POSIX_PATH_MAX]; - if (stat (path, &st) == -1) + if (S_ISDIR(st->st_mode)) return (-1); - if (st.st_size == 0) { + if (st->st_size == 0) { /* hard to tell what zero-length files are, so assume the default magic */ if (DefaultMagic == M_MBOX || DefaultMagic == M_MMDF) return (DefaultMagic); @@ -1186,8 +1185,8 @@ int mbox_is_magic (const char* path) { * only the type was accessed. This is important, because detection * of "new mail" depends on those times set correctly. */ - times.actime = st.st_atime; - times.modtime = st.st_mtime; + times.actime = st->st_atime; + times.modtime = st->st_mtime; utime (path, ×); #endif } else { @@ -1196,7 +1195,7 @@ int mbox_is_magic (const char* path) { } #ifdef USE_COMPRESSED - if (magic == 0 && mutt_can_read_compressed (path)) + if (magic == -1 && mutt_can_read_compressed (path)) return (M_COMPRESSED); #endif return (magic);