From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Add "scandir" procedure Date: Mon, 19 Dec 2011 22:38:48 +0100 Message-ID: <87r500tf6f.fsf@gnu.org> References: <1314475521.3143.47.camel@Renee-desktop> <87ty4xmxl1.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1324330747 16421 80.91.229.12 (19 Dec 2011 21:39:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 19 Dec 2011 21:39:07 +0000 (UTC) Cc: guile-devel@gnu.org To: Nala Ginrut Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Dec 19 22:39:02 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RckvF-00041S-2i for guile-devel@m.gmane.org; Mon, 19 Dec 2011 22:39:01 +0100 Original-Received: from localhost ([::1]:41858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RckvE-0002Zf-8x for guile-devel@m.gmane.org; Mon, 19 Dec 2011 16:39:00 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:47311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RckvC-0002ZY-As for guile-devel@gnu.org; Mon, 19 Dec 2011 16:38:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RckvB-0006x0-4V for guile-devel@gnu.org; Mon, 19 Dec 2011 16:38:58 -0500 Original-Received: from mail4-relais-sop.national.inria.fr ([192.134.164.105]:9053) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RckvA-0006wh-W2 for guile-devel@gnu.org; Mon, 19 Dec 2011 16:38:57 -0500 X-IronPort-AV: E=Sophos;i="4.71,378,1320620400"; d="scan'208";a="123963125" Original-Received: from reverse-83.fdn.fr (HELO pluto) ([80.67.176.83]) by mail4-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 19 Dec 2011 22:38:54 +0100 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 29 Frimaire an 220 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: (Nala Ginrut's message of "Tue, 20 Dec 2011 03:20:59 +0800") User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.134.164.105 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:13164 Archived-At: Hi Nala! Thanks for testing! Nala Ginrut skribis: > 1. I think file-system-fold based scandir tried to traverse the whole > directories include sub-directories. It's rather slow for a deep one if I > just > want a files list under 0 level directory tree; The code had initially approximately 1 typo per line, and I think I=E2=80= =99ve fixed most of them now. ;-) So =E2=80=98scandir=E2=80=99 does not enter sub-directories. If it does, t= hat=E2=80=99s another bug. :-) > 2. New scandir will crash while encounters a Chinese file name. This will > be eliminated by using (setlocale LC_ALL "zh_CN.UTF-8"). > I think it's the same problem we faced in another thread. There's > something locale problem in Guile. Of course, we have a temporary solution > in recent commit; Yes, Guile views file names as strings and decodes them from the current locale encoding. So if there are file names encoded differently, then scm_from_locale_string, called by =E2=80=98readdir=E2=80=99, throws a decod= ing-error. That=E2=80=99s unfortunate, I=E2=80=99m not sure what to do. I think GLib/= GIO issues a warning in such cases, while still being able to handle the file. We could imagine =E2=80=98readdir=E2=80=99 returning a raw bytevector when dec= oding fails, and =E2=80=98open-file=E2=80=99 & co. could accept it as input. But that= =E2=80=99s really ugly. I think Mark had some ideas about it, which would be worth checking. > 3. It returns weird result. E.g (scandir "mmr") > =3D=3D> ("." "." "." ".." ".." ".." "aa.c" "exclude" "ml" "myecl") One of the typos that got fixed, hopefully. :-) Can you check again? > Anyway, I think new scandir's cool. Though it's little slow than my C wrap > version Because it uses =E2=80=98file-system-fold=E2=80=99, it does one =E2=80=98st= at=E2=80=99 call for each file, which the C version doesn=E2=80=99t do. That should be the only efficiency difference. Maybe we could change our =E2=80=98scandir=E2=80=99 to return a list of fil= e name/stat pairs since we have the info anyway? Thanks, Ludo=E2=80=99.