Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id ACDCC431FBC for ; Wed, 25 Nov 2009 12:12:29 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LYzVyRwG5zgM for ; Wed, 25 Nov 2009 12:12:29 -0800 (PST) Received: from megan.quadhome.com (megan.quadhome.com [209.9.237.126]) by olra.theworths.org (Postfix) with ESMTP id 1F61B431FAE for ; Wed, 25 Nov 2009 12:12:29 -0800 (PST) Received: from elise.quadhome.com (97-126-47-108.tukw.qwest.net [97.126.47.108]) by megan.quadhome.com (Postfix) with ESMTPSA id D44A9B8032 for ; Wed, 25 Nov 2009 12:12:27 -0800 (PST) Content-Type: text/plain; charset=UTF-8 From: Scott Robinson To: notmuch In-reply-to: <1259178195-30324-1-git-send-email-jan@ryngle.com> References: <1259178195-30324-1-git-send-email-jan@ryngle.com> Date: Wed, 25 Nov 2009 12:12:25 -0800 Message-Id: <1259179778-sup-5382@lisa> User-Agent: Sup/0.9 Content-Transfer-Encoding: 8bit Subject: Re: [notmuch] [PATCH] notmuch-new: Test if directory looks like Maildir before skipping tmp. X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Nov 2009 20:12:29 -0000 Excerpts from Jan Janak's message of Wed Nov 25 11:43:15 -0800 2009: > +/* Test if the directory looks like a Maildir directory. > + * > + * Search through the array of directory entries to see if we can find all > + * three subdirectories typical for Maildir, that is "new", "cur", and "tmp". > + * > + * Return 1 if the directory looks like a Maildir and 0 otherwise. > + */ > +static int is_maildir (struct dirent **entries, int count) > +{ > + int i, found = 0; > + > + for (i = 0; i < count; i++) { > + if (entries[i]->d_type != DT_DIR) continue; > + if (strcmp(entries[i]->d_name, "new") == 0 || > + strcmp(entries[i]->d_name, "cur") == 0 || > + strcmp(entries[i]->d_name, "tmp") == 0) > + { > + found++; > + } > + } > + > + return found >= 3; > +} Maybe put the "found >= 3" in the for loop's stop-condition? -- Scott Robinson | http://quadhome.com/ Q: Why are my replies five sentences or less? A: http://five.sentenc.es/