Mercurial > hg > xemacs-beta
comparison src/realpath.c @ 462:0784d089fdc9 r21-2-46
Import from CVS: tag r21-2-46
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:44:37 +0200 |
parents | 1ccc32a20af4 |
children | ed498ef2108b |
comparison
equal
deleted
inserted
replaced
461:120ed4009e51 | 462:0784d089fdc9 |
---|---|
135 /* Call readlink and try to find out the correct case for the file. */ | 135 /* Call readlink and try to find out the correct case for the file. */ |
136 static int | 136 static int |
137 cygwin_readlink (const char * name, char * buf, int size) | 137 cygwin_readlink (const char * name, char * buf, int size) |
138 { | 138 { |
139 int n = readlink (name, buf, size); | 139 int n = readlink (name, buf, size); |
140 if (n < 0) | 140 if (n < 0 && errno == EINVAL) |
141 { | 141 { |
142 /* The file may exist, but isn't a symlink. Try to find the | 142 /* The file may exist, but isn't a symlink. Try to find the |
143 right name. */ | 143 right name. */ |
144 char* tmp = alloca (cygwin_posix_to_win32_path_list_buf_size (name)); | 144 char* tmp = alloca (cygwin_posix_to_win32_path_list_buf_size (name)); |
145 cygwin_posix_to_win32_path_list (name, tmp); | 145 cygwin_posix_to_win32_path_list (name, tmp); |
206 #ifdef WIN32_NATIVE | 206 #ifdef WIN32_NATIVE |
207 /* Check for c:/... or //server/... */ | 207 /* Check for c:/... or //server/... */ |
208 if (abslen == 2 || abslen == 3) | 208 if (abslen == 2 || abslen == 3) |
209 { | 209 { |
210 strncpy (new_path, path, abslen); | 210 strncpy (new_path, path, abslen); |
211 /* Make sure drive letter is lowercased. */ | |
212 if (abslen == 3) | |
213 *new_path = tolower (*new_path); | |
211 new_path += abslen; | 214 new_path += abslen; |
212 path += abslen; | 215 path += abslen; |
213 } | 216 } |
214 /* No drive letter, but a beginning slash? Prepend drive letter. */ | 217 /* No drive letter, but a beginning slash? Prepend drive letter. */ |
215 else if (abslen == 1) | 218 else if (abslen == 1) |
297 n = system_readlink (resolved_path, link_path, PATH_MAX - 1); | 300 n = system_readlink (resolved_path, link_path, PATH_MAX - 1); |
298 | 301 |
299 if (n < 0) | 302 if (n < 0) |
300 { | 303 { |
301 /* EINVAL means the file exists but isn't a symlink. */ | 304 /* EINVAL means the file exists but isn't a symlink. */ |
302 if (errno != EINVAL) | 305 #ifdef CYGWIN |
306 if (errno != EINVAL && errno != ENOENT) | |
307 #else | |
308 if (errno != EINVAL) | |
309 #endif | |
303 return NULL; | 310 return NULL; |
304 } | 311 } |
305 else | 312 else |
306 { | 313 { |
307 /* Protect against infinite loops. */ | 314 /* Protect against infinite loops. */ |
343 new_path--; | 350 new_path--; |
344 | 351 |
345 /* Make sure it's null terminated. */ | 352 /* Make sure it's null terminated. */ |
346 *new_path = '\0'; | 353 *new_path = '\0'; |
347 | 354 |
348 #ifdef WIN32_NATIVE | |
349 if (ABS_LENGTH (resolved_path) == 3) | |
350 /* Lowercase drive letter. */ | |
351 *resolved_path = tolower (*resolved_path); | |
352 #endif | |
353 return resolved_path; | 355 return resolved_path; |
354 } | 356 } |