help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Portable dir-path separator?


From: Michael Heerdegen
Subject: Re: Portable dir-path separator?
Date: Wed, 26 Jun 2013 20:31:00 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Hi Thorsten,

> 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.


Regards,

Michael.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]