comparison src/fileio.c @ 373:6240c7796c7a r21-2b2

Import from CVS: tag r21-2b2
author cvs
date Mon, 13 Aug 2007 11:04:06 +0200
parents cc15677e0335
children d883f39b8495
comparison
equal deleted inserted replaced
372:49e1ed2d7ed8 373:6240c7796c7a
452 { 452 {
453 /* MAXPATHLEN+1 is guaranteed to be enough space for getdefdir. */ 453 /* MAXPATHLEN+1 is guaranteed to be enough space for getdefdir. */
454 Bufbyte *res = alloca (MAXPATHLEN + 1); 454 Bufbyte *res = alloca (MAXPATHLEN + 1);
455 if (getdefdir (toupper (*beg) - 'A' + 1, res)) 455 if (getdefdir (toupper (*beg) - 'A' + 1, res))
456 { 456 {
457 if (!IS_DIRECTORY_SEP (res[strlen ((char *) res) - 1])) 457 char *c=((char *) res) + strlen ((char *) res);
458 strcat ((char *) res, "/"); 458 if (!IS_DIRECTORY_SEP (*c))
459 {
460 *c++ = DIRECTORY_SEP;
461 *c = '\0';
462 }
459 beg = res; 463 beg = res;
460 p = beg + strlen ((char *) beg); 464 p = beg + strlen ((char *) beg);
461 } 465 }
462 } 466 }
463 CORRECT_DIR_SEPS (beg);
464 #endif /* WINDOWSNT */ 467 #endif /* WINDOWSNT */
465 return make_string (beg, p - beg); 468 return make_string (beg, p - beg);
466 } 469 }
467 470
468 DEFUN ("file-name-nondirectory", Ffile_name_nondirectory, 1, 1, 0, /* 471 DEFUN ("file-name-nondirectory", Ffile_name_nondirectory, 1, 1, 0, /*
542 { 545 {
543 out[size] = DIRECTORY_SEP; 546 out[size] = DIRECTORY_SEP;
544 out[size + 1] = '\0'; 547 out[size + 1] = '\0';
545 } 548 }
546 } 549 }
547 #ifdef WINDOWSNT
548 CORRECT_DIR_SEPS (out);
549 #endif
550 return out; 550 return out;
551 } 551 }
552 552
553 DEFUN ("file-name-as-directory", Ffile_name_as_directory, 1, 1, 0, /* 553 DEFUN ("file-name-as-directory", Ffile_name_as_directory, 1, 1, 0, /*
554 Return a string representing file FILENAME interpreted as a directory. 554 Return a string representing file FILENAME interpreted as a directory.
606 && !IS_ANY_SEP (dst[slen - 2]) 606 && !IS_ANY_SEP (dst[slen - 2])
607 #endif /* WINDOWSNT */ 607 #endif /* WINDOWSNT */
608 ) 608 )
609 dst[slen - 1] = 0; 609 dst[slen - 1] = 0;
610 #endif /* APOLLO */ 610 #endif /* APOLLO */
611 #ifdef WINDOWSNT
612 CORRECT_DIR_SEPS (dst);
613 #endif /* WINDOWSNT */
614 return 1; 611 return 1;
615 } 612 }
616 613
617 DEFUN ("directory-file-name", Fdirectory_file_name, 1, 1, 0, /* 614 DEFUN ("directory-file-name", Fdirectory_file_name, 1, 1, 0, /*
618 Return the file name of the directory named DIR. 615 Return the file name of the directory named DIR.
2286 call the corresponding file handler. */ 2283 call the corresponding file handler. */
2287 handler = Ffind_file_name_handler (abspath, Qfile_readable_p); 2284 handler = Ffind_file_name_handler (abspath, Qfile_readable_p);
2288 if (!NILP (handler)) 2285 if (!NILP (handler))
2289 RETURN_UNGCPRO (call2 (handler, Qfile_readable_p, abspath)); 2286 RETURN_UNGCPRO (call2 (handler, Qfile_readable_p, abspath));
2290 2287
2291 #ifdef WINDOWSNT 2288 #if defined(WINDOWSNT) || defined(__CYGWIN32__)
2292 /* Under MS-DOS and Windows, open does not work for directories. */ 2289 /* Under MS-DOS and Windows, open does not work for directories. */
2293 UNGCPRO; 2290 UNGCPRO;
2294 if (access (XSTRING_DATA (abspath), 0) == 0) 2291 if (access (XSTRING_DATA (abspath), 0) == 0)
2295 return Qt; 2292 return Qt;
2296 else 2293 else