From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: zulian jc Newsgroups: gmane.lisp.guile.user Subject: Fail stating a file not in current folder Date: Wed, 17 Sep 2008 10:06:30 +0200 Message-ID: <200809171006.30175.jzu@imtf.ch> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1221640621 14983 80.91.229.12 (17 Sep 2008 08:37:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Sep 2008 08:37:01 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Sep 17 10:37:57 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KfsXs-0006AF-N4 for guile-user@m.gmane.org; Wed, 17 Sep 2008 10:37:57 +0200 Original-Received: from localhost ([127.0.0.1]:60558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KfsWr-0007mS-EW for guile-user@m.gmane.org; Wed, 17 Sep 2008 04:36:53 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KfsWl-0007lQ-Ad for guile-user@gnu.org; Wed, 17 Sep 2008 04:36:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KfsWg-0007kR-C0 for guile-user@gnu.org; Wed, 17 Sep 2008 04:36:46 -0400 Original-Received: from [199.232.76.173] (port=39528 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KfsWf-0007k9-Rq for guile-user@gnu.org; Wed, 17 Sep 2008 04:36:41 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:40252) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KfsWf-0005wu-Hd for guile-user@gnu.org; Wed, 17 Sep 2008 04:36:41 -0400 Original-Received: from smtp.imtf.ch ([194.209.33.5] helo=srvweb.imtf.ch) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KfsWc-0001cc-2v for guile-user@gnu.org; Wed, 17 Sep 2008 04:36:38 -0400 Original-Received: from 192.168.255.40 [192.168.255.40] by srvweb.imtf.ch with XWall v3.40 ; Wed, 17 Sep 2008 10:06:24 +0200 Original-Received: from wsjzu.imtf.local ([192.168.2.166]) by srvexch.IMTF.LOCAL with Microsoft SMTPSVC(6.0.3790.3959); Wed, 17 Sep 2008 10:06:30 +0200 User-Agent: KMail/1.9.9 Content-Disposition: inline X-OriginalArrivalTime: 17 Sep 2008 08:06:30.0412 (UTC) FILETIME=[4AB524C0:01C9189C] X-detected-kernel: by mx20.gnu.org: Windows 2000 SP4, XP SP1+ X-Greylist: delayed 1803 seconds by postgrey-1.27 at nadesico; Wed, 17 Sep 2008 04:36:35 EDT X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:6770 Archived-At: Hello guile list, I am new to guile and scheme so excuse my poor coding. Anyway I am faced with a little problem with guile 1.8.1. I am writing a function that collects all sub-directory from a given directory. To do this I am using the opendir and readdir functions. However it happens that if I am not cd'ing into the directory I want to browse, the following function failed. Is that a normal behavior? (define gather-dirs (lambda (path) ;; with the following line commented out the function will fail browsing ;; directories other than the current one ;;(chdir path) (let ((cdir (opendir path)) (l '())) (do ((entry (readdir cdir) (readdir cdir))) ((eof-object? entry) l) (if (directory? entry) (set! l (cons entry l))))))) (define directory? (lambda (x) (eq? (stat:type (stat x)) 'directory))) Here is the error I get back: ERROR: In procedure stat: ERROR: No such file or directory: ".bb" Note: '.bb' is a folder that exist in the folder I want to browse but not in the current one. So basicaly 'readdir' and 'opendir' did their job fine but when I am trying to stat on the found entry it fails (in the 'directory?' function). Investigating further I saw that 'readdir' just return a string with the name of the folder entry, that is a name relative to the folder opened by 'opendir'. Say I am browsing '/home/bob' folder then readdir will return me as an entry "bin" and not "/home/bob/bin". Hence 'stat' is failing if there is no 'bin' folder in current folder. Is that correct? Now how could one browse a folder and stat on each entry without having to change to that folder? Thanks in advance for your help, jc