From: zulian jc <jzu@imtf.ch>
To: guile-user@gnu.org
Subject: Fail stating a file not in current folder
Date: Wed, 17 Sep 2008 10:06:30 +0200 [thread overview]
Message-ID: <200809171006.30175.jzu@imtf.ch> (raw)
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
next reply other threads:[~2008-09-17 8:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-17 8:06 zulian jc [this message]
2008-09-17 8:59 ` Fail stating a file not in current folder Neil Jerram
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200809171006.30175.jzu@imtf.ch \
--to=jzu@imtf.ch \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).