[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how having the basename of a file or directory
From: |
Stefan Monnier |
Subject: |
Re: how having the basename of a file or directory |
Date: |
Mon, 31 Jan 2011 10:29:05 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
> Yes thanks, that's work too, but it would be nice to do not have to take
> care of that:
> (file-name-nondirectory "path/to/a/directory")
> should return ==> directory
It does.
> (file-name-nondirectory "path/to/a/file")
> should return ==> file
It does.
> So modifying `file-name-nondirectory' or creating a basename function
> or macro like:
> (defun basename (fname)
> (if (file-directory-p fname)
> (let ((dirname (directory-file-name fname)))
> (file-name-nondirectory dirname))
> (file-name-nondirectory fname)))
That won't work on (basename "/non/existing/thing/").
You really want to use (file-name-nondirectory (directory-file-name fname))
Stefan
- how having the basename of a file or directory, Thierry Volpiatto, 2011/01/31
- how having the basename of a file or directory, Stephen J. Turnbull, 2011/01/31
- Re: how having the basename of a file or directory, Thierry Volpiatto, 2011/01/31
- Re: how having the basename of a file or directory, Andreas Schwab, 2011/01/31
- Re: how having the basename of a file or directory, Thierry Volpiatto, 2011/01/31
- Re: how having the basename of a file or directory, Andreas Schwab, 2011/01/31
- Re: how having the basename of a file or directory, Thierry Volpiatto, 2011/01/31
- Re: how having the basename of a file or directory, Andreas Schwab, 2011/01/31
- Re: how having the basename of a file or directory,
Stefan Monnier <=
- Re: how having the basename of a file or directory, Thierry Volpiatto, 2011/01/31
- Re: how having the basename of a file or directory, Karl Fogel, 2011/01/31
- Re: how having the basename of a file or directory, Stefan Monnier, 2011/01/31
- Re: how having the basename of a file or directory, Thierry Volpiatto, 2011/01/31