comparison src/fileio.c @ 116:9f59509498e1 r20-1b10

Import from CVS: tag r20-1b10
author cvs
date Mon, 13 Aug 2007 09:23:06 +0200
parents 8619ce7e4c50
children cca96a509cfe
comparison
equal deleted inserted replaced
115:f109f7dabbe2 116:9f59509498e1
340 but we still do run any other handlers. This lets handlers 340 but we still do run any other handlers. This lets handlers
341 use the standard functions without calling themselves recursively. 341 use the standard functions without calling themselves recursively.
342 */ 342 */
343 (filename, operation)) 343 (filename, operation))
344 { 344 {
345 /* This function does not GC */
345 /* This function must not munge the match data. */ 346 /* This function must not munge the match data. */
346 Lisp_Object chain, inhibited_handlers; 347 Lisp_Object chain, inhibited_handlers;
347 348
348 CHECK_STRING (filename); 349 CHECK_STRING (filename);
349 350
374 } 375 }
375 376
376 static Lisp_Object 377 static Lisp_Object
377 call2_check_string (Lisp_Object fn, Lisp_Object arg0, Lisp_Object arg1) 378 call2_check_string (Lisp_Object fn, Lisp_Object arg0, Lisp_Object arg1)
378 { 379 {
379 /* This function can GC */ 380 /* This function can call lisp */
380 Lisp_Object result = call2 (fn, arg0, arg1); 381 Lisp_Object result = call2 (fn, arg0, arg1);
381 CHECK_STRING (result); 382 CHECK_STRING (result);
382 return (result); 383 return (result);
383 } 384 }
384 385
385 static Lisp_Object 386 static Lisp_Object
386 call2_check_string_or_nil (Lisp_Object fn, Lisp_Object arg0, Lisp_Object arg1) 387 call2_check_string_or_nil (Lisp_Object fn, Lisp_Object arg0, Lisp_Object arg1)
387 { 388 {
388 /* This function can GC */ 389 /* This function can call lisp */
389 Lisp_Object result = call2 (fn, arg0, arg1); 390 Lisp_Object result = call2 (fn, arg0, arg1);
390 if (!NILP (result)) 391 if (!NILP (result))
391 CHECK_STRING (result); 392 CHECK_STRING (result);
392 return (result); 393 return (result);
393 } 394 }
394 395
395 static Lisp_Object 396 static Lisp_Object
396 call3_check_string (Lisp_Object fn, Lisp_Object arg0, 397 call3_check_string (Lisp_Object fn, Lisp_Object arg0,
397 Lisp_Object arg1, Lisp_Object arg2) 398 Lisp_Object arg1, Lisp_Object arg2)
398 { 399 {
399 /* This function can GC */ 400 /* This function can call lisp */
400 Lisp_Object result = call3 (fn, arg0, arg1, arg2); 401 Lisp_Object result = call3 (fn, arg0, arg1, arg2);
401 CHECK_STRING (result); 402 CHECK_STRING (result);
402 return (result); 403 return (result);
403 } 404 }
404 405
410 Given a Unix syntax file name, returns a string ending in slash; 411 Given a Unix syntax file name, returns a string ending in slash;
411 on VMS, perhaps instead a string ending in `:', `]' or `>'. 412 on VMS, perhaps instead a string ending in `:', `]' or `>'.
412 */ 413 */
413 (file)) 414 (file))
414 { 415 {
415 /* This function can GC */ 416 /* This function can call lisp */
416 Bufbyte *beg; 417 Bufbyte *beg;
417 Bufbyte *p; 418 Bufbyte *p;
418 Lisp_Object handler; 419 Lisp_Object handler;
419 420
420 CHECK_STRING (file); 421 CHECK_STRING (file);
478 this is everything after the last slash, 479 this is everything after the last slash,
479 or the entire name if it contains no slash. 480 or the entire name if it contains no slash.
480 */ 481 */
481 (file)) 482 (file))
482 { 483 {
483 /* This function can GC */ 484 /* This function can call lisp */
484 Bufbyte *beg, *p, *end; 485 Bufbyte *beg, *p, *end;
485 Lisp_Object handler; 486 Lisp_Object handler;
486 487
487 CHECK_STRING (file); 488 CHECK_STRING (file);
488 489
514 The `call-process' and `start-process' functions use this function to 515 The `call-process' and `start-process' functions use this function to
515 get a current directory to run processes in. 516 get a current directory to run processes in.
516 */ 517 */
517 (filename)) 518 (filename))
518 { 519 {
519 /* This function can GC */ 520 /* This function can call lisp */
520 Lisp_Object handler; 521 Lisp_Object handler;
521 522
522 /* If the file name has special constructs in it, 523 /* If the file name has special constructs in it,
523 call the corresponding file handler. */ 524 call the corresponding file handler. */
524 handler = Ffind_file_name_handler (filename, Qunhandled_file_name_directory); 525 handler = Ffind_file_name_handler (filename, Qunhandled_file_name_directory);
614 For a Unix-syntax file name, just appends a slash. 615 For a Unix-syntax file name, just appends a slash.
615 On VMS, converts \"[X]FOO.DIR\" to \"[X.FOO]\", etc. 616 On VMS, converts \"[X]FOO.DIR\" to \"[X.FOO]\", etc.
616 */ 617 */
617 (file)) 618 (file))
618 { 619 {
619 /* This function can GC */ 620 /* This function can call lisp */
620 char *buf; 621 char *buf;
621 Lisp_Object handler; 622 Lisp_Object handler;
622 623
623 CHECK_STRING (file); 624 CHECK_STRING (file);
624 625
800 On VMS, given a VMS-syntax directory name such as \"[X.Y]\", 801 On VMS, given a VMS-syntax directory name such as \"[X.Y]\",
801 it returns a file name such as \"[X]Y.DIR.1\". 802 it returns a file name such as \"[X]Y.DIR.1\".
802 */ 803 */
803 (directory)) 804 (directory))
804 { 805 {
805 /* This function can GC */ 806 /* This function can call lisp */
806 char *buf; 807 char *buf;
807 Lisp_Object handler; 808 Lisp_Object handler;
808 809
809 CHECK_STRING (directory); 810 CHECK_STRING (directory);
810 811
868 An initial `~USER/' expands to USER's home directory. 869 An initial `~USER/' expands to USER's home directory.
869 See also the function `substitute-in-file-name'. 870 See also the function `substitute-in-file-name'.
870 */ 871 */
871 (name, defalt)) 872 (name, defalt))
872 { 873 {
873 /* This function can GC */ 874 /* This function can call lisp */
874 Bufbyte *nm; 875 Bufbyte *nm;
875 876
876 Bufbyte *newdir, *p, *o; 877 Bufbyte *newdir, *p, *o;
877 int tlen; 878 int tlen;
878 Bufbyte *target; 879 Bufbyte *target;
938 that would need adjusting, and people would add new pointers to 939 that would need adjusting, and people would add new pointers to
939 the code and forget to adjust them, resulting in intermittent bugs. 940 the code and forget to adjust them, resulting in intermittent bugs.
940 Putting this call here avoids all that crud. 941 Putting this call here avoids all that crud.
941 942
942 The EQ test avoids infinite recursion. */ 943 The EQ test avoids infinite recursion. */
943 if (! NILP (defalt) && !EQ (defalt, name) 944 if (! NILP(defalt) && !EQ (defalt, name)
944 /* This saves time in a common case. */ 945 /* This saves time in a common case. */
945 && ! (XSTRING_LENGTH (defalt) >= 3 946 && ! (XSTRING_LENGTH (defalt) >= 3
946 && IS_DIRECTORY_SEP (XSTRING_BYTE (defalt, 0)) 947 && (IS_DIRECTORY_SEP (XSTRING_BYTE (defalt, 0))
947 && IS_DEVICE_SEP (XSTRING_BYTE (defalt, 1)))) 948 || IS_DEVICE_SEP (XSTRING_BYTE (defalt, 1)))))
948 { 949 {
949 struct gcpro gcpro1; 950 struct gcpro gcpro1;
950 951
951 GCPRO1 (defalt); /* may be current_buffer->directory */ 952 GCPRO1 (defalt); /* may be current_buffer->directory */
952 defalt = Fexpand_file_name (defalt, Qnil); 953 defalt = Fexpand_file_name (defalt, Qnil);
1398 No component of the resulting pathname will be a symbolic link, as 1399 No component of the resulting pathname will be a symbolic link, as
1399 in the realpath() function. 1400 in the realpath() function.
1400 */ 1401 */
1401 (filename, defalt)) 1402 (filename, defalt))
1402 { 1403 {
1403 /* This function can GC */ 1404 /* This function can call lisp */
1404 struct gcpro gcpro1; 1405 struct gcpro gcpro1;
1405 Lisp_Object expanded_name; 1406 Lisp_Object expanded_name;
1406 Lisp_Object handler; 1407 Lisp_Object handler;
1407 1408
1408 CHECK_STRING (filename); 1409 CHECK_STRING (filename);
1525 On VMS, `$' substitution is not done; this function does little and only 1526 On VMS, `$' substitution is not done; this function does little and only
1526 duplicates what `expand-file-name' does. 1527 duplicates what `expand-file-name' does.
1527 */ 1528 */
1528 (string)) 1529 (string))
1529 { 1530 {
1531 /* This function can call lisp */
1530 Bufbyte *nm; 1532 Bufbyte *nm;
1531 1533
1532 Bufbyte *s, *p, *o, *x, *endp; 1534 Bufbyte *s, *p, *o, *x, *endp;
1533 Bufbyte *target = 0; 1535 Bufbyte *target = 0;
1534 int total = 0; 1536 int total = 0;
1735 /* (directory-file-name (expand-file-name FOO)) */ 1737 /* (directory-file-name (expand-file-name FOO)) */
1736 1738
1737 Lisp_Object 1739 Lisp_Object
1738 expand_and_dir_to_file (Lisp_Object filename, Lisp_Object defdir) 1740 expand_and_dir_to_file (Lisp_Object filename, Lisp_Object defdir)
1739 { 1741 {
1740 /* This function can GC */ 1742 /* This function can call lisp */
1741 Lisp_Object abspath; 1743 Lisp_Object abspath;
1742 struct gcpro gcpro1; 1744 struct gcpro gcpro1;
1743 1745
1744 GCPRO1 (filename);
1745 abspath = Fexpand_file_name (filename, defdir); 1746 abspath = Fexpand_file_name (filename, defdir);
1747 GCPRO1 (abspath);
1746 #ifdef VMS 1748 #ifdef VMS
1747 { 1749 {
1748 Bufbyte c = 1750 Bufbyte c =
1749 XSTRING_BYTE (abspath, XSTRING_LENGTH (abspath) - 1); 1751 XSTRING_BYTE (abspath, XSTRING_LENGTH (abspath) - 1);
1750 if (c == ':' || c == ']' || c == '>') 1752 if (c == ':' || c == ']' || c == '>')
1773 1775
1774 static void 1776 static void
1775 barf_or_query_if_file_exists (Lisp_Object absname, CONST char *querystring, 1777 barf_or_query_if_file_exists (Lisp_Object absname, CONST char *querystring,
1776 int interactive, struct stat *statptr) 1778 int interactive, struct stat *statptr)
1777 { 1779 {
1780 /* This function can call lisp */
1778 struct stat statbuf; 1781 struct stat statbuf;
1779 1782
1780 /* stat is a good way to tell whether the file exists, 1783 /* stat is a good way to tell whether the file exists,
1781 regardless of what access permissions it has. */ 1784 regardless of what access permissions it has. */
1782 if (stat ((char *) XSTRING_DATA (absname), &statbuf) >= 0) 1785 if (stat ((char *) XSTRING_DATA (absname), &statbuf) >= 0)
1783 { 1786 {
1784 Lisp_Object tem; 1787 Lisp_Object tem;
1785 struct gcpro gcpro1; 1788
1786
1787 GCPRO1 (absname);
1788 if (interactive) 1789 if (interactive)
1789 tem = call1 1790 {
1790 (Qyes_or_no_p, 1791 Lisp_Object prompt;
1791 (emacs_doprnt_string_c 1792 struct gcpro gcpro1;
1793
1794 prompt = emacs_doprnt_string_c
1792 ((CONST Bufbyte *) GETTEXT ("File %s already exists; %s anyway? "), 1795 ((CONST Bufbyte *) GETTEXT ("File %s already exists; %s anyway? "),
1793 Qnil, -1, XSTRING_DATA (absname), 1796 Qnil, -1, XSTRING_DATA (absname),
1794 GETTEXT (querystring)))); 1797 GETTEXT (querystring));
1798
1799 GCPRO1 (prompt);
1800 tem = call1 (Qyes_or_no_p, prompt);
1801 UNGCPRO;
1802 }
1795 else 1803 else
1796 tem = Qnil; 1804 tem = Qnil;
1797 UNGCPRO; 1805
1798 if (NILP (tem)) 1806 if (NILP (tem))
1799 Fsignal (Qfile_already_exists, 1807 Fsignal (Qfile_already_exists,
1800 list2 (build_translated_string ("File already exists"), 1808 list2 (build_translated_string ("File already exists"),
1801 absname)); 1809 absname));
1802 if (statptr) 1810 if (statptr)
1821 last-modified time as the old one. (This works on only some systems.) 1829 last-modified time as the old one. (This works on only some systems.)
1822 A prefix arg makes KEEP-TIME non-nil. 1830 A prefix arg makes KEEP-TIME non-nil.
1823 */ 1831 */
1824 (filename, newname, ok_if_already_exists, keep_time)) 1832 (filename, newname, ok_if_already_exists, keep_time))
1825 { 1833 {
1826 /* This function can GC */ 1834 /* This function can call lisp */
1827 int ifd, ofd, n; 1835 int ifd, ofd, n;
1828 char buf[16 * 1024]; 1836 char buf[16 * 1024];
1829 struct stat st, out_st; 1837 struct stat st, out_st;
1830 Lisp_Object handler; 1838 Lisp_Object handler;
1831 int speccount = specpdl_depth (); 1839 int speccount = specpdl_depth ();
1987 DEFUN ("make-directory-internal", Fmake_directory_internal, 1, 1, 0, /* 1995 DEFUN ("make-directory-internal", Fmake_directory_internal, 1, 1, 0, /*
1988 Create a directory. One argument, a file name string. 1996 Create a directory. One argument, a file name string.
1989 */ 1997 */
1990 (dirname)) 1998 (dirname))
1991 { 1999 {
1992 /* This function can GC */ 2000 /* This function can call lisp */
1993 char dir [MAXPATHLEN]; 2001 char dir [MAXPATHLEN];
1994 Lisp_Object handler; 2002 Lisp_Object handler;
1995 struct gcpro gcpro1; 2003 struct gcpro gcpro1;
1996 2004
1997 CHECK_STRING (dirname); 2005 CHECK_STRING (dirname);
2031 DEFUN ("delete-directory", Fdelete_directory, 1, 1, "FDelete directory: ", /* 2039 DEFUN ("delete-directory", Fdelete_directory, 1, 1, "FDelete directory: ", /*
2032 Delete a directory. One argument, a file name or directory name string. 2040 Delete a directory. One argument, a file name or directory name string.
2033 */ 2041 */
2034 (dirname)) 2042 (dirname))
2035 { 2043 {
2036 /* This function can GC */ 2044 /* This function can call lisp */
2037 Lisp_Object handler; 2045 Lisp_Object handler;
2038 struct gcpro gcpro1; 2046 struct gcpro gcpro1;
2039 2047
2040 CHECK_STRING (dirname); 2048 CHECK_STRING (dirname);
2041 2049
2058 Delete specified file. One argument, a file name string. 2066 Delete specified file. One argument, a file name string.
2059 If file has multiple names, it continues to exist with the other names. 2067 If file has multiple names, it continues to exist with the other names.
2060 */ 2068 */
2061 (filename)) 2069 (filename))
2062 { 2070 {
2063 /* This function can GC */ 2071 /* This function can call lisp */
2064 Lisp_Object handler; 2072 Lisp_Object handler;
2065 struct gcpro gcpro1; 2073 struct gcpro gcpro1;
2066 2074
2067 CHECK_STRING (filename); 2075 CHECK_STRING (filename);
2068 filename = Fexpand_file_name (filename, Qnil); 2076 filename = Fexpand_file_name (filename, Qnil);
2087 /* Delete file FILENAME, returning 1 if successful and 0 if failed. */ 2095 /* Delete file FILENAME, returning 1 if successful and 0 if failed. */
2088 2096
2089 int 2097 int
2090 internal_delete_file (Lisp_Object filename) 2098 internal_delete_file (Lisp_Object filename)
2091 { 2099 {
2100 /* This function can call lisp */
2092 return NILP (condition_case_1 (Qt, Fdelete_file, filename, 2101 return NILP (condition_case_1 (Qt, Fdelete_file, filename,
2093 internal_delete_file_1, Qnil)); 2102 internal_delete_file_1, Qnil));
2094 } 2103 }
2095 2104
2096 DEFUN ("rename-file", Frename_file, 2, 3, 2105 DEFUN ("rename-file", Frename_file, 2, 3,
2102 A number as third arg means request confirmation if NEWNAME already exists. 2111 A number as third arg means request confirmation if NEWNAME already exists.
2103 This is what happens in interactive use with M-x. 2112 This is what happens in interactive use with M-x.
2104 */ 2113 */
2105 (filename, newname, ok_if_already_exists)) 2114 (filename, newname, ok_if_already_exists))
2106 { 2115 {
2107 /* This function can GC */ 2116 /* This function can call lisp */
2108 Lisp_Object handler; 2117 Lisp_Object handler;
2109 struct gcpro gcpro1, gcpro2; 2118 struct gcpro gcpro1, gcpro2;
2110 2119
2111 GCPRO2 (filename, newname); 2120 GCPRO2 (filename, newname);
2112 CHECK_STRING (filename); 2121 CHECK_STRING (filename);
2195 A number as third arg means request confirmation if NEWNAME already exists. 2204 A number as third arg means request confirmation if NEWNAME already exists.
2196 This is what happens in interactive use with M-x. 2205 This is what happens in interactive use with M-x.
2197 */ 2206 */
2198 (filename, newname, ok_if_already_exists)) 2207 (filename, newname, ok_if_already_exists))
2199 { 2208 {
2200 /* This function can GC */ 2209 /* This function can call lisp */
2201 Lisp_Object handler; 2210 Lisp_Object handler;
2202 struct gcpro gcpro1, gcpro2; 2211 struct gcpro gcpro1, gcpro2;
2203 2212
2204 GCPRO2 (filename, newname); 2213 GCPRO2 (filename, newname);
2205 CHECK_STRING (filename); 2214 CHECK_STRING (filename);
2252 A number as third arg means request confirmation if LINKNAME already exists. 2261 A number as third arg means request confirmation if LINKNAME already exists.
2253 This happens for interactive use with M-x. 2262 This happens for interactive use with M-x.
2254 */ 2263 */
2255 (filename, linkname, ok_if_already_exists)) 2264 (filename, linkname, ok_if_already_exists))
2256 { 2265 {
2257 /* This function can GC */ 2266 /* This function can call lisp */
2258 Lisp_Object handler; 2267 Lisp_Object handler;
2259 struct gcpro gcpro1, gcpro2; 2268 struct gcpro gcpro1, gcpro2;
2260 2269
2261 GCPRO2 (filename, linkname); 2270 GCPRO2 (filename, linkname);
2262 CHECK_STRING (filename); 2271 CHECK_STRING (filename);
2360 Return t if file FILENAME specifies an absolute path name. 2369 Return t if file FILENAME specifies an absolute path name.
2361 On Unix, this is a name starting with a `/' or a `~'. 2370 On Unix, this is a name starting with a `/' or a `~'.
2362 */ 2371 */
2363 (filename)) 2372 (filename))
2364 { 2373 {
2374 /* This function does not GC */
2365 Bufbyte *ptr; 2375 Bufbyte *ptr;
2366 2376
2367 CHECK_STRING (filename); 2377 CHECK_STRING (filename);
2368 ptr = XSTRING_DATA (filename); 2378 ptr = XSTRING_DATA (filename);
2369 if (IS_DIRECTORY_SEP (*ptr) || *ptr == '~' 2379 if (IS_DIRECTORY_SEP (*ptr) || *ptr == '~'
2439 Return t if file FILENAME exists. (This does not mean you can read it.) 2449 Return t if file FILENAME exists. (This does not mean you can read it.)
2440 See also `file-readable-p' and `file-attributes'. 2450 See also `file-readable-p' and `file-attributes'.
2441 */ 2451 */
2442 (filename)) 2452 (filename))
2443 { 2453 {
2444 /* This function can GC */ 2454 /* This function can call lisp */
2445 Lisp_Object abspath; 2455 Lisp_Object abspath;
2446 Lisp_Object handler; 2456 Lisp_Object handler;
2447 struct stat statbuf; 2457 struct stat statbuf;
2448 struct gcpro gcpro1; 2458 struct gcpro gcpro1;
2449 2459
2450 GCPRO1 (filename);
2451 CHECK_STRING (filename); 2460 CHECK_STRING (filename);
2452 abspath = Fexpand_file_name (filename, Qnil); 2461 abspath = Fexpand_file_name (filename, Qnil);
2453 UNGCPRO;
2454 2462
2455 /* If the file name has special constructs in it, 2463 /* If the file name has special constructs in it,
2456 call the corresponding file handler. */ 2464 call the corresponding file handler. */
2457 GCPRO1 (abspath); 2465 GCPRO1 (abspath);
2458 handler = Ffind_file_name_handler (abspath, Qfile_exists_p); 2466 handler = Ffind_file_name_handler (abspath, Qfile_exists_p);
2471 For a directory, this means you can access files in that directory. 2479 For a directory, this means you can access files in that directory.
2472 */ 2480 */
2473 (filename)) 2481 (filename))
2474 2482
2475 { 2483 {
2476 /* This function can GC */ 2484 /* This function can call lisp */
2477 Lisp_Object abspath; 2485 Lisp_Object abspath;
2478 Lisp_Object handler; 2486 Lisp_Object handler;
2479 struct gcpro gcpro1; 2487 struct gcpro gcpro1;
2480 2488
2481 GCPRO1 (filename);
2482 CHECK_STRING (filename); 2489 CHECK_STRING (filename);
2483 abspath = Fexpand_file_name (filename, Qnil); 2490 abspath = Fexpand_file_name (filename, Qnil);
2484 UNGCPRO;
2485 2491
2486 /* If the file name has special constructs in it, 2492 /* If the file name has special constructs in it,
2487 call the corresponding file handler. */ 2493 call the corresponding file handler. */
2488 GCPRO1 (abspath); 2494 GCPRO1 (abspath);
2489 handler = Ffind_file_name_handler (abspath, Qfile_executable_p); 2495 handler = Ffind_file_name_handler (abspath, Qfile_executable_p);
2499 Return t if file FILENAME exists and you can read it. 2505 Return t if file FILENAME exists and you can read it.
2500 See also `file-exists-p' and `file-attributes'. 2506 See also `file-exists-p' and `file-attributes'.
2501 */ 2507 */
2502 (filename)) 2508 (filename))
2503 { 2509 {
2504 /* This function can GC */ 2510 /* This function can call lisp */
2505 Lisp_Object abspath; 2511 Lisp_Object abspath;
2506 Lisp_Object handler; 2512 Lisp_Object handler;
2507 int desc; 2513 int desc;
2508 struct gcpro gcpro1; 2514 struct gcpro gcpro1;
2509 2515
2532 DEFUN ("file-writable-p", Ffile_writable_p, 1, 1, 0, /* 2538 DEFUN ("file-writable-p", Ffile_writable_p, 1, 1, 0, /*
2533 Return t if file FILENAME can be written or created by you. 2539 Return t if file FILENAME can be written or created by you.
2534 */ 2540 */
2535 (filename)) 2541 (filename))
2536 { 2542 {
2537 /* This function can GC */ 2543 /* This function can call lisp */
2538 Lisp_Object abspath, dir; 2544 Lisp_Object abspath, dir;
2539 Lisp_Object handler; 2545 Lisp_Object handler;
2540 struct stat statbuf; 2546 struct stat statbuf;
2541 struct gcpro gcpro1; 2547 struct gcpro gcpro1;
2542 2548
2543 GCPRO1 (filename);
2544 CHECK_STRING (filename); 2549 CHECK_STRING (filename);
2545 abspath = Fexpand_file_name (filename, Qnil); 2550 abspath = Fexpand_file_name (filename, Qnil);
2546 UNGCPRO;
2547 2551
2548 /* If the file name has special constructs in it, 2552 /* If the file name has special constructs in it,
2549 call the corresponding file handler. */ 2553 call the corresponding file handler. */
2550 GCPRO1 (abspath); 2554 GCPRO1 (abspath);
2551 handler = Ffind_file_name_handler (abspath, Qfile_writable_p); 2555 handler = Ffind_file_name_handler (abspath, Qfile_writable_p);
2579 The value is the name of the file to which it is linked. 2583 The value is the name of the file to which it is linked.
2580 Otherwise returns nil. 2584 Otherwise returns nil.
2581 */ 2585 */
2582 (filename)) 2586 (filename))
2583 { 2587 {
2584 /* This function can GC */ 2588 /* This function can call lisp */
2585 #ifdef S_IFLNK 2589 #ifdef S_IFLNK
2586 char *buf; 2590 char *buf;
2587 int bufsize; 2591 int bufsize;
2588 int valsize; 2592 int valsize;
2589 Lisp_Object val; 2593 Lisp_Object val;
2590 Lisp_Object handler; 2594 Lisp_Object handler;
2591 struct gcpro gcpro1; 2595 struct gcpro gcpro1;
2592 2596
2593 GCPRO1 (filename);
2594 CHECK_STRING (filename); 2597 CHECK_STRING (filename);
2595 filename = Fexpand_file_name (filename, Qnil); 2598 filename = Fexpand_file_name (filename, Qnil);
2596 UNGCPRO;
2597 2599
2598 /* If the file name has special constructs in it, 2600 /* If the file name has special constructs in it,
2599 call the corresponding file handler. */ 2601 call the corresponding file handler. */
2602 GCPRO1 (filename);
2600 handler = Ffind_file_name_handler (filename, Qfile_symlink_p); 2603 handler = Ffind_file_name_handler (filename, Qfile_symlink_p);
2604 UNGCPRO;
2601 if (!NILP (handler)) 2605 if (!NILP (handler))
2602 return call2 (handler, Qfile_symlink_p, filename); 2606 return call2 (handler, Qfile_symlink_p, filename);
2603 2607
2604 bufsize = 100; 2608 bufsize = 100;
2605 while (1) 2609 while (1)
2631 A directory name spec may be given instead; then the value is t 2635 A directory name spec may be given instead; then the value is t
2632 if the directory so specified exists and really is a directory. 2636 if the directory so specified exists and really is a directory.
2633 */ 2637 */
2634 (filename)) 2638 (filename))
2635 { 2639 {
2636 /* This function can GC */ 2640 /* This function can call lisp */
2637 Lisp_Object abspath; 2641 Lisp_Object abspath;
2638 struct stat st; 2642 struct stat st;
2639 Lisp_Object handler; 2643 Lisp_Object handler;
2640 struct gcpro gcpro1; 2644 struct gcpro gcpro1;
2641 2645
2665 if the directory so specified exists and really is a readable and 2669 if the directory so specified exists and really is a readable and
2666 searchable directory. 2670 searchable directory.
2667 */ 2671 */
2668 (filename)) 2672 (filename))
2669 { 2673 {
2670 /* This function can GC */ 2674 /* This function can call lisp */
2671 Lisp_Object handler; 2675 Lisp_Object handler;
2672 struct gcpro gcpro1;
2673 2676
2674 /* If the file name has special constructs in it, 2677 /* If the file name has special constructs in it,
2675 call the corresponding file handler. */ 2678 call the corresponding file handler. */
2676 handler = Ffind_file_name_handler (filename, Qfile_accessible_directory_p); 2679 handler = Ffind_file_name_handler (filename, Qfile_accessible_directory_p);
2677 if (!NILP (handler)) 2680 if (!NILP (handler))
2678 return call2 (handler, Qfile_accessible_directory_p, 2681 return call2 (handler, Qfile_accessible_directory_p,
2679 filename); 2682 filename);
2680 2683
2681 /* #### dmoore - this gcpro on filename should be unneccesary since
2682 the caller should ahve already protected it. */
2683 GCPRO1 (filename);
2684 if (NILP (Ffile_directory_p (filename))) 2684 if (NILP (Ffile_directory_p (filename)))
2685 {
2686 UNGCPRO;
2687 return (Qnil); 2685 return (Qnil);
2688 } 2686 else
2689 handler = Ffile_executable_p (filename); 2687 return Ffile_executable_p (filename);
2690 UNGCPRO;
2691 return (handler);
2692 } 2688 }
2693 2689
2694 DEFUN ("file-regular-p", Ffile_regular_p, 1, 1, 0, /* 2690 DEFUN ("file-regular-p", Ffile_regular_p, 1, 1, 0, /*
2695 "Return t if file FILENAME is the name of a regular file. 2691 "Return t if file FILENAME is the name of a regular file.
2696 This is the sort of file that holds an ordinary stream of data bytes. 2692 This is the sort of file that holds an ordinary stream of data bytes.
2697 */ 2693 */
2698 (filename)) 2694 (filename))
2699 { 2695 {
2696 /* This function can call lisp */
2700 Lisp_Object abspath; 2697 Lisp_Object abspath;
2701 struct stat st; 2698 struct stat st;
2702 Lisp_Object handler; 2699 Lisp_Object handler;
2703 struct gcpro gcpro1; 2700 struct gcpro gcpro1;
2704 2701
2722 DEFUN ("file-modes", Ffile_modes, 1, 1, 0, /* 2719 DEFUN ("file-modes", Ffile_modes, 1, 1, 0, /*
2723 Return mode bits of FILE, as an integer. 2720 Return mode bits of FILE, as an integer.
2724 */ 2721 */
2725 (filename)) 2722 (filename))
2726 { 2723 {
2727 /* This function can GC */ 2724 /* This function can call lisp */
2728 Lisp_Object abspath; 2725 Lisp_Object abspath;
2729 struct stat st; 2726 struct stat st;
2730 Lisp_Object handler; 2727 Lisp_Object handler;
2731 struct gcpro gcpro1; 2728 struct gcpro gcpro1;
2732 2729
2757 Set mode bits of FILE to MODE (an integer). 2754 Set mode bits of FILE to MODE (an integer).
2758 Only the 12 low bits of MODE are used. 2755 Only the 12 low bits of MODE are used.
2759 */ 2756 */
2760 (filename, mode)) 2757 (filename, mode))
2761 { 2758 {
2762 /* This function can GC */ 2759 /* This function can call lisp */
2763 Lisp_Object abspath; 2760 Lisp_Object abspath;
2764 Lisp_Object handler; 2761 Lisp_Object handler;
2765 struct gcpro gcpro1; 2762 struct gcpro gcpro1;
2766 2763
2767 GCPRO1 (current_buffer->directory); 2764 GCPRO1 (current_buffer->directory);
2768 abspath = Fexpand_file_name (filename, current_buffer->directory); 2765 abspath = Fexpand_file_name (filename, current_buffer->directory);
2766 UNGCPRO;
2767
2769 CHECK_INT (mode); 2768 CHECK_INT (mode);
2770 UNGCPRO;
2771 2769
2772 /* If the file name has special constructs in it, 2770 /* If the file name has special constructs in it,
2773 call the corresponding file handler. */ 2771 call the corresponding file handler. */
2774 GCPRO1 (abspath); 2772 GCPRO1 (abspath);
2775 handler = Ffind_file_name_handler (abspath, Qset_file_modes); 2773 handler = Ffind_file_name_handler (abspath, Qset_file_modes);
2834 If FILE1 does not exist, the answer is nil; 2832 If FILE1 does not exist, the answer is nil;
2835 otherwise, if FILE2 does not exist, the answer is t. 2833 otherwise, if FILE2 does not exist, the answer is t.
2836 */ 2834 */
2837 (file1, file2)) 2835 (file1, file2))
2838 { 2836 {
2839 /* This function can GC */ 2837 /* This function can call lisp */
2840 Lisp_Object abspath1, abspath2; 2838 Lisp_Object abspath1, abspath2;
2841 struct stat st; 2839 struct stat st;
2842 int mtime1; 2840 int mtime1;
2843 Lisp_Object handler; 2841 Lisp_Object handler;
2844 struct gcpro gcpro1, gcpro2, gcpro3; 2842 struct gcpro gcpro1, gcpro2, gcpro3;
2900 Currently BEG and END refer to byte positions (as opposed to character 2898 Currently BEG and END refer to byte positions (as opposed to character
2901 positions), even in Mule. (Fixing this is very difficult.) 2899 positions), even in Mule. (Fixing this is very difficult.)
2902 */ 2900 */
2903 (filename, visit, beg, end, replace, codesys, used_codesys)) 2901 (filename, visit, beg, end, replace, codesys, used_codesys))
2904 { 2902 {
2905 /* This function can GC */ 2903 /* This function can call lisp */
2904 /* #### dmoore - this function hasn't been checked for gc recently */
2906 struct stat st; 2905 struct stat st;
2907 int fd; 2906 int fd;
2908 int saverrno = 0; 2907 int saverrno = 0;
2909 Charcount inserted = 0; 2908 Charcount inserted = 0;
2910 int speccount; 2909 int speccount;
3362 If support for Mule exists in this Emacs, the file is encoded according 3361 If support for Mule exists in this Emacs, the file is encoded according
3363 to the value of CODESYS. If this is nil, no code conversion occurs. 3362 to the value of CODESYS. If this is nil, no code conversion occurs.
3364 */ 3363 */
3365 (start, end, filename, append, visit, lockname, codesys)) 3364 (start, end, filename, append, visit, lockname, codesys))
3366 { 3365 {
3367 /* This function can GC */ 3366 /* This function can call lisp */
3368 int desc; 3367 int desc;
3369 int failure; 3368 int failure;
3370 int save_errno = 0; 3369 int save_errno = 0;
3371 struct stat st; 3370 struct stat st;
3372 Lisp_Object fn; 3371 Lisp_Object fn;
4015 Return t if last mod time of BUF's visited file matches what BUF records. 4014 Return t if last mod time of BUF's visited file matches what BUF records.
4016 This means that the file has not been changed since it was visited or saved. 4015 This means that the file has not been changed since it was visited or saved.
4017 */ 4016 */
4018 (buf)) 4017 (buf))
4019 { 4018 {
4020 /* This function can GC */ 4019 /* This function can call lisp */
4021 struct buffer *b; 4020 struct buffer *b;
4022 struct stat st; 4021 struct stat st;
4023 Lisp_Object handler; 4022 Lisp_Object handler;
4024 4023
4025 CHECK_BUFFER (buf); 4024 CHECK_BUFFER (buf);
4081 (instead of that of the visited file), in the form of a list 4080 (instead of that of the visited file), in the form of a list
4082 (HIGH . LOW) or (HIGH LOW). 4081 (HIGH . LOW) or (HIGH LOW).
4083 */ 4082 */
4084 (time_list)) 4083 (time_list))
4085 { 4084 {
4086 /* This function can GC */ 4085 /* This function can call lisp */
4087 if (!NILP (time_list)) 4086 if (!NILP (time_list))
4088 { 4087 {
4089 time_t the_time; 4088 time_t the_time;
4090 lisp_to_time (time_list, &the_time); 4089 lisp_to_time (time_list, &the_time);
4091 current_buffer->modtime = (int) the_time; 4090 current_buffer->modtime = (int) the_time;
4120 current time. In either case, if the optional arg TIME is supplied, 4119 current time. In either case, if the optional arg TIME is supplied,
4121 it will be used if it is either an integer or a cons of two integers. 4120 it will be used if it is either an integer or a cons of two integers.
4122 */ 4121 */
4123 (buf, in_time)) 4122 (buf, in_time))
4124 { 4123 {
4125 /* This function can GC */ 4124 /* This function can call lisp */
4126 unsigned long time_to_use = 0; 4125 unsigned long time_to_use = 0;
4127 int set_time_to_use = 0; 4126 int set_time_to_use = 0;
4128 struct stat st; 4127 struct stat st;
4129 4128
4130 CHECK_BUFFER (buf); 4129 CHECK_BUFFER (buf);
4194 4193
4195 4194
4196 static Lisp_Object 4195 static Lisp_Object
4197 auto_save_error (Lisp_Object condition_object, Lisp_Object ignored) 4196 auto_save_error (Lisp_Object condition_object, Lisp_Object ignored)
4198 { 4197 {
4199 /* This function can GC */ 4198 /* This function can call lisp */
4200 if (gc_in_progress) 4199 if (gc_in_progress)
4201 return Qnil; 4200 return Qnil;
4202 /* Don't try printing an error message after everything is gone! */ 4201 /* Don't try printing an error message after everything is gone! */
4203 if (preparing_for_armageddon) 4202 if (preparing_for_armageddon)
4204 return Qnil; 4203 return Qnil;
4214 } 4213 }
4215 4214
4216 static Lisp_Object 4215 static Lisp_Object
4217 auto_save_1 (Lisp_Object ignored) 4216 auto_save_1 (Lisp_Object ignored)
4218 { 4217 {
4219 /* This function can GC */ 4218 /* This function can call lisp */
4219 /* #### I think caller is protecting current_buffer? */
4220 struct stat st; 4220 struct stat st;
4221 Lisp_Object fn = current_buffer->filename; 4221 Lisp_Object fn = current_buffer->filename;
4222 Lisp_Object a = current_buffer->auto_save_file_name; 4222 Lisp_Object a = current_buffer->auto_save_file_name;
4223 4223
4224 if (!STRINGP (a)) 4224 if (!STRINGP (a))
4244 Qnil 4244 Qnil
4245 #endif 4245 #endif
4246 ); 4246 );
4247 } 4247 }
4248 4248
4249 static Lisp_Object
4250 auto_save_expand_name_error (Lisp_Object condition_object, Lisp_Object ignored)
4251 {
4252 /* #### this function should spew an error message about not being
4253 able to open the .saves file. */
4254 return Qnil;
4255 }
4256
4257 static Lisp_Object
4258 auto_save_expand_name (Lisp_Object name)
4259 {
4260 struct gcpro gcpro1;
4261
4262 /* note that caller did NOT gc protect name, so we do it. */
4263 /* #### dmoore - this might not be neccessary, if condition_case_1
4264 protects it. but I don't think it does. */
4265 GCPRO1 (name);
4266 RETURN_UNGCPRO (Fexpand_file_name (name, Qnil));
4267 }
4268
4249 4269
4250 static Lisp_Object 4270 static Lisp_Object
4251 do_auto_save_unwind (Lisp_Object fd) 4271 do_auto_save_unwind (Lisp_Object fd)
4252 { 4272 {
4253 close (XINT (fd)); 4273 close (XINT (fd));
4281 Non-nil first argument means do not print any message if successful. 4301 Non-nil first argument means do not print any message if successful.
4282 Non-nil second argument means save only current buffer. 4302 Non-nil second argument means save only current buffer.
4283 */ 4303 */
4284 (no_message, current_only)) 4304 (no_message, current_only))
4285 { 4305 {
4286 /* This function can GC */ 4306 /* This function can call lisp */
4287 struct buffer *b; 4307 struct buffer *b;
4288 Lisp_Object tail, buf; 4308 Lisp_Object tail, buf;
4289 int auto_saved = 0; 4309 int auto_saved = 0;
4290 int do_handled_files; 4310 int do_handled_files;
4291 Lisp_Object oquit = Qnil; 4311 Lisp_Object oquit = Qnil;
4310 no_message = Qt; 4330 no_message = Qt;
4311 4331
4312 run_hook (Qauto_save_hook); 4332 run_hook (Qauto_save_hook);
4313 4333
4314 if (GC_STRINGP (Vauto_save_list_file_name)) 4334 if (GC_STRINGP (Vauto_save_list_file_name))
4315 listfile = Fexpand_file_name (Vauto_save_list_file_name, Qnil); 4335 listfile = condition_case_1 (Qt,
4336 auto_save_expand_name,
4337 Vauto_save_list_file_name,
4338 auto_save_expand_name_error, Qnil);
4316 4339
4317 /* Make sure auto_saving is reset. */ 4340 /* Make sure auto_saving is reset. */
4318 record_unwind_protect (do_auto_save_unwind_2, make_int (auto_saving)); 4341 record_unwind_protect (do_auto_save_unwind_2, make_int (auto_saving));
4319 4342
4320 auto_saving = 1; 4343 auto_saving = 1;