diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 81 |
1 files changed, 57 insertions, 24 deletions
diff --git a/src/fileio.c b/src/fileio.c index f3f8f421618..70799eb2cd1 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2251,33 +2251,66 @@ internal_delete_file (Lisp_Object filename) | |||
| 2251 | static bool | 2251 | static bool |
| 2252 | file_name_case_insensitive_p (const char *filename) | 2252 | file_name_case_insensitive_p (const char *filename) |
| 2253 | { | 2253 | { |
| 2254 | #ifdef DOS_NT | 2254 | /* Use pathconf with _PC_CASE_INSENSITIVE or _PC_CASE_SENSITIVE if |
| 2255 | return 1; | 2255 | those flags are available. As of this writing (2016-11-14), |
| 2256 | #elif defined CYGWIN | 2256 | Cygwin is the only platform known to support the former (starting |
| 2257 | /* As of Cygwin-2.6.1, pathconf supports _PC_CASE_INSENSITIVE. */ | 2257 | with Cygwin-2.6.1), and Mac OS X is the only platform known to |
| 2258 | # ifdef _PC_CASE_INSENSITIVE | 2258 | support the latter. |
| 2259 | |||
| 2260 | There have been reports that pathconf with _PC_CASE_SENSITIVE | ||
| 2261 | does not work reliably on Mac OS X. If you have a problem, | ||
| 2262 | please recompile Emacs with -DDARWIN_OS_CASE_SENSITIVE_FIXME=1 or | ||
| 2263 | -DDARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying | ||
| 2264 | whether this fixed your problem. */ | ||
| 2265 | |||
| 2266 | #ifdef _PC_CASE_INSENSITIVE | ||
| 2259 | int res = pathconf (filename, _PC_CASE_INSENSITIVE); | 2267 | int res = pathconf (filename, _PC_CASE_INSENSITIVE); |
| 2260 | if (res < 0) | 2268 | if (res >= 0) |
| 2261 | return 1; | 2269 | return res > 0; |
| 2262 | return res > 0; | 2270 | #elif defined _PC_CASE_SENSITIVE && !defined DARWIN_OS_CASE_SENSITIVE_FIXME |
| 2263 | # else | 2271 | int res = pathconf (filename, _PC_CASE_SENSITIVE); |
| 2264 | return 1; | 2272 | if (res >= 0) |
| 2273 | return res == 0; | ||
| 2274 | #endif | ||
| 2275 | |||
| 2276 | #ifdef DARWIN_OS | ||
| 2277 | # ifndef DARWIN_OS_CASE_SENSITIVE_FIXME | ||
| 2278 | int DARWIN_OS_CASE_SENSITIVE_FIXME = 0; | ||
| 2265 | # endif | 2279 | # endif |
| 2266 | #elif defined DARWIN_OS | 2280 | |
| 2267 | /* The following is based on | 2281 | if (DARWIN_OS_CASE_SENSITIVE_FIXME == 1) |
| 2268 | http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */ | 2282 | { |
| 2269 | struct attrlist alist; | 2283 | /* This is based on developer.apple.com's getattrlist man page. */ |
| 2270 | unsigned char buffer[sizeof (vol_capabilities_attr_t) + sizeof (size_t)]; | 2284 | struct attrlist alist = {.volattr = ATTR_VOL_CAPABILITIES}; |
| 2271 | 2285 | struct vol_capabilities_attr_t vcaps; | |
| 2272 | memset (&alist, 0, sizeof (alist)); | 2286 | if (getattrlist (filename, &alist, &vcaps, sizeof vcaps, 0) == 0) |
| 2273 | alist.volattr = ATTR_VOL_CAPABILITIES; | 2287 | { |
| 2274 | if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0) | 2288 | if (vcaps.valid[VOL_CAPABILITIES_FORMAT] & VOL_CAP_FMT_CASE_SENSITIVE) |
| 2275 | || !(alist.volattr & ATTR_VOL_CAPABILITIES)) | 2289 | return ! (vcaps.capabilities[VOL_CAPABILITIES_FORMAT] |
| 2276 | return 0; | 2290 | & VOL_CAP_FMT_CASE_SENSITIVE); |
| 2277 | vol_capabilities_attr_t *vcaps = buffer; | 2291 | } |
| 2278 | return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE); | 2292 | } |
| 2293 | else if (DARWIN_OS_CASE_SENSITIVE_FIXME == 2) | ||
| 2294 | { | ||
| 2295 | /* The following is based on | ||
| 2296 | http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */ | ||
| 2297 | struct attrlist alist; | ||
| 2298 | unsigned char buffer[sizeof (vol_capabilities_attr_t) sizeof (size_t)]; | ||
| 2299 | |||
| 2300 | memset (&alist, 0, sizeof (alist)); | ||
| 2301 | alist.volattr = ATTR_VOL_CAPABILITIES; | ||
| 2302 | if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0) | ||
| 2303 | || !(alist.volattr & ATTR_VOL_CAPABILITIES)) | ||
| 2304 | return 0; | ||
| 2305 | vol_capabilities_attr_t *vcaps = buffer; | ||
| 2306 | return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE); | ||
| 2307 | } | ||
| 2308 | #endif /* DARWIN_OS */ | ||
| 2309 | |||
| 2310 | #if defined CYGWIN || defined DOS_NT | ||
| 2311 | return true; | ||
| 2279 | #else | 2312 | #else |
| 2280 | return 0; | 2313 | return false; |
| 2281 | #endif | 2314 | #endif |
| 2282 | } | 2315 | } |
| 2283 | 2316 | ||