[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Portable dir-path separator?
From: |
Thorsten Jolitz |
Subject: |
Re: Portable dir-path separator? |
Date: |
Wed, 26 Jun 2013 20:56:24 +0200 |
User-agent: |
Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux) |
Michael Heerdegen <michael_heerdegen@web.de> writes:
Hi Michael,
>> is it portable to split absolute file names in Emacs Lisp with "/" as
>> separator? I searched for a related variable that abstracts away the
>> slash vs. backslash issue, but did not find one (`path-separator' is ':'
>> under GNU/Linux and probably not what I'm looking for).
>
> I think you want something like
>
> (defun split-path (path)
> (split-path-1 path ()))
>
> (defun split-path-1 (path accum)
> (let ((dir (directory-file-name (file-name-directory path)))
> (name (file-name-nondirectory path)))
> (if (equal dir path)
> accum
> (split-path-1 dir (cons name accum)))))
>
> I totally agree that something like that could be built in.
Exactly what I wanted (and actually expected to be built in somehow).
Thanks!
--
cheers,
Thorsten