[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] [PATCH] Strip all trailing slashes from directory path
From: |
Evan Hanson |
Subject: |
[Chicken-hackers] [PATCH] Strip all trailing slashes from directory pathname parts |
Date: |
Sat, 1 Jun 2013 01:18:42 -0700 |
User-agent: |
OpenSMTPD enqueuer (Demoosh) |
Kristian found the following behavior yesterday:
#;> (create-directory "./abc//def/ghi" 'recursively)
Error: (create-directory) cannot create directory - File exists: "./abc/"
...
The reason for this error is that `create-directory` loops on the
successive results of `pathname-directory` on the path, but
`decompose-pathname` (over which `pathname-directory` is defined) only
drops one trailing slash from directory pathname parts, even if more are
present. So, CHICKEN mkdirs "./abc" and then "./abc/", causing this
error.
The attached patch causes `decompose-pathname` (and its derivatives
`pathname-directory`, `pathname-replace-file`, etc.) to strip all
trailing slashes from the directory parts of pathnames, rather than just
the last one. It also adds a handful of tests for `decompose-pathname`.
One might say you should always call `normalize-pathname` first, but
even so I think `decompose-pathname` should either trim all trailing
slashes or none, and this change makes it more closely resemble
dirname's behavior (and makes more sense anyway, IMHO).
Cheers,
Evan
0001-Strip-all-trailing-slashes-from-directory-pathname-p.patch
Description: Text document
- [Chicken-hackers] [PATCH] Strip all trailing slashes from directory pathname parts,
Evan Hanson <=