[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Portably know the name of the filesystem root directory
From: |
Stefan Monnier |
Subject: |
Re: Portably know the name of the filesystem root directory |
Date: |
Wed, 28 Mar 2012 19:25:03 -0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux) |
> (while (not (setq sandboxes (directory-files dir t ".*\\.pj$" t)))
> (when (string= dir "/")
> (error "no sandbox found"))
> (setq dir (file-name-directory dir)))
If you think about it, you don't really care about "reaching the root".
You care more about "not getting stuck in an infinite loop".
So you should be able to get what you want by checking that you're
still making progress, e.g. by checking that `dir' is getting smaller at
each iteration.
You might also want to take a look at locate-dominating-file (and
locate-dominating-files which is commented out, in the same file).
Stefan