comparison src/fileio.c @ 20:859a2309aef8 r19-15b93

Import from CVS: tag r19-15b93
author cvs
date Mon, 13 Aug 2007 08:50:05 +0200
parents 0293115a14e9
children e04119814345
comparison
equal deleted inserted replaced
19:ac1f612d5250 20:859a2309aef8
319 Lisp_Object Qset_buffer_modtime; 319 Lisp_Object Qset_buffer_modtime;
320 320
321 /* If FILENAME is handled specially on account of its syntax, 321 /* If FILENAME is handled specially on account of its syntax,
322 return its handler function. Otherwise, return nil. */ 322 return its handler function. Otherwise, return nil. */
323 323
324 DEFUN ("find-file-name-handler", 324 DEFUN ("find-file-name-handler", Ffind_file_name_handler, 1, 2, 0, /*
325 Ffind_file_name_handler, Sfind_file_name_handler, 1, 2, 0 /*
326 Return FILENAME's handler function for OPERATION, if it has one. 325 Return FILENAME's handler function for OPERATION, if it has one.
327 Otherwise, return nil. 326 Otherwise, return nil.
328 A file name is handled if one of the regular expressions in 327 A file name is handled if one of the regular expressions in
329 `file-name-handler-alist' matches it. 328 `file-name-handler-alist' matches it.
330 329
331 If OPERATION equals `inhibit-file-name-operation', then we ignore 330 If OPERATION equals `inhibit-file-name-operation', then we ignore
332 any handlers that are members of `inhibit-file-name-handlers', 331 any handlers that are members of `inhibit-file-name-handlers',
333 but we still do run any other handlers. This lets handlers 332 but we still do run any other handlers. This lets handlers
334 use the standard functions without calling themselves recursively. 333 use the standard functions without calling themselves recursively.
335 */ ) 334 */
336 (filename, operation) 335 (filename, operation))
337 Lisp_Object filename, operation;
338 { 336 {
339 /* This function must not munge the match data. */ 337 /* This function must not munge the match data. */
340 Lisp_Object chain, inhibited_handlers; 338 Lisp_Object chain, inhibited_handlers;
341 339
342 CHECK_STRING (filename); 340 CHECK_STRING (filename);
385 CHECK_STRING (result); 383 CHECK_STRING (result);
386 return (result); 384 return (result);
387 } 385 }
388 386
389 387
390 DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, 388 DEFUN ("file-name-directory", Ffile_name_directory, 1, 1, 0, /*
391 1, 1, 0 /*
392 Return the directory component in file name NAME. 389 Return the directory component in file name NAME.
393 Return nil if NAME does not include a directory. 390 Return nil if NAME does not include a directory.
394 Otherwise return a directory spec. 391 Otherwise return a directory spec.
395 Given a Unix syntax file name, returns a string ending in slash; 392 Given a Unix syntax file name, returns a string ending in slash;
396 on VMS, perhaps instead a string ending in `:', `]' or `>'. 393 on VMS, perhaps instead a string ending in `:', `]' or `>'.
397 */ ) 394 */
398 (file) 395 (file))
399 Lisp_Object file;
400 { 396 {
401 /* This function can GC */ 397 /* This function can GC */
402 Bufbyte *beg; 398 Bufbyte *beg;
403 Bufbyte *p; 399 Bufbyte *p;
404 Lisp_Object handler; 400 Lisp_Object handler;
462 } 458 }
463 #endif /* DOS_NT */ 459 #endif /* DOS_NT */
464 return make_string (beg, p - beg); 460 return make_string (beg, p - beg);
465 } 461 }
466 462
467 DEFUN ("file-name-nondirectory", Ffile_name_nondirectory, 463 DEFUN ("file-name-nondirectory", Ffile_name_nondirectory, 1, 1, 0, /*
468 Sfile_name_nondirectory,
469 1, 1, 0 /*
470 Return file name NAME sans its directory. 464 Return file name NAME sans its directory.
471 For example, in a Unix-syntax file name, 465 For example, in a Unix-syntax file name,
472 this is everything after the last slash, 466 this is everything after the last slash,
473 or the entire name if it contains no slash. 467 or the entire name if it contains no slash.
474 */ ) 468 */
475 (file) 469 (file))
476 Lisp_Object file;
477 { 470 {
478 /* This function can GC */ 471 /* This function can GC */
479 Bufbyte *beg, *p, *end; 472 Bufbyte *beg, *p, *end;
480 Lisp_Object handler; 473 Lisp_Object handler;
481 474
498 ) p--; 491 ) p--;
499 492
500 return make_string (p, end - p); 493 return make_string (p, end - p);
501 } 494 }
502 495
503 DEFUN ("unhandled-file-name-directory", 496 DEFUN ("unhandled-file-name-directory", Funhandled_file_name_directory, 1, 1, 0, /*
504 Funhandled_file_name_directory, Sunhandled_file_name_directory, 1, 1, 0 /*
505 Return a directly usable directory name somehow associated with FILENAME. 497 Return a directly usable directory name somehow associated with FILENAME.
506 A `directly usable' directory name is one that may be used without the 498 A `directly usable' directory name is one that may be used without the
507 intervention of any file handler. 499 intervention of any file handler.
508 If FILENAME is a directly usable file itself, return 500 If FILENAME is a directly usable file itself, return
509 (file-name-directory FILENAME). 501 (file-name-directory FILENAME).
510 The `call-process' and `start-process' functions use this function to 502 The `call-process' and `start-process' functions use this function to
511 get a current directory to run processes in. 503 get a current directory to run processes in.
512 */ ) 504 */
513 (filename) 505 (filename))
514 Lisp_Object filename;
515 { 506 {
516 /* This function can GC */ 507 /* This function can GC */
517 Lisp_Object handler; 508 Lisp_Object handler;
518 509
519 /* If the file name has special constructs in it, 510 /* If the file name has special constructs in it,
600 } 591 }
601 #endif /* not VMS */ 592 #endif /* not VMS */
602 return out; 593 return out;
603 } 594 }
604 595
605 DEFUN ("file-name-as-directory", Ffile_name_as_directory, 596 DEFUN ("file-name-as-directory", Ffile_name_as_directory, 1, 1, 0, /*
606 Sfile_name_as_directory, 1, 1, 0 /*
607 Return a string representing file FILENAME interpreted as a directory. 597 Return a string representing file FILENAME interpreted as a directory.
608 This operation exists because a directory is also a file, but its name as 598 This operation exists because a directory is also a file, but its name as
609 a directory is different from its name as a file. 599 a directory is different from its name as a file.
610 The result can be used as the value of `default-directory' 600 The result can be used as the value of `default-directory'
611 or passed as second argument to `expand-file-name'. 601 or passed as second argument to `expand-file-name'.
612 For a Unix-syntax file name, just appends a slash. 602 For a Unix-syntax file name, just appends a slash.
613 On VMS, converts \"[X]FOO.DIR\" to \"[X.FOO]\", etc. 603 On VMS, converts \"[X]FOO.DIR\" to \"[X.FOO]\", etc.
614 */ ) 604 */
615 (file) 605 (file))
616 Lisp_Object file;
617 { 606 {
618 /* This function can GC */ 607 /* This function can GC */
619 char *buf; 608 char *buf;
620 Lisp_Object handler; 609 Lisp_Object handler;
621 610
788 dst[slen - 1] = 0; 777 dst[slen - 1] = 0;
789 #endif 778 #endif
790 return 1; 779 return 1;
791 } 780 }
792 781
793 DEFUN ("directory-file-name", Fdirectory_file_name, Sdirectory_file_name, 782 DEFUN ("directory-file-name", Fdirectory_file_name, 1, 1, 0, /*
794 1, 1, 0 /*
795 Return the file name of the directory named DIR. 783 Return the file name of the directory named DIR.
796 This is the name of the file that holds the data for the directory DIR. 784 This is the name of the file that holds the data for the directory DIR.
797 This operation exists because a directory is also a file, but its name as 785 This operation exists because a directory is also a file, but its name as
798 a directory is different from its name as a file. 786 a directory is different from its name as a file.
799 In Unix-syntax, this function just removes the final slash. 787 In Unix-syntax, this function just removes the final slash.
800 On VMS, given a VMS-syntax directory name such as \"[X.Y]\", 788 On VMS, given a VMS-syntax directory name such as \"[X.Y]\",
801 it returns a file name such as \"[X]Y.DIR.1\". 789 it returns a file name such as \"[X]Y.DIR.1\".
802 */ ) 790 */
803 (directory) 791 (directory))
804 Lisp_Object directory;
805 { 792 {
806 /* This function can GC */ 793 /* This function can GC */
807 char *buf; 794 char *buf;
808 Lisp_Object handler; 795 Lisp_Object handler;
809 796
830 #endif 817 #endif
831 directory_file_name ((char *) XSTRING_DATA (directory), buf); 818 directory_file_name ((char *) XSTRING_DATA (directory), buf);
832 return build_string (buf); 819 return build_string (buf);
833 } 820 }
834 821
835 DEFUN ("make-temp-name", Fmake_temp_name, Smake_temp_name, 1, 1, 0 /* 822 DEFUN ("make-temp-name", Fmake_temp_name, 1, 1, 0, /*
836 Generate temporary file name (string) starting with PREFIX (a string). 823 Generate temporary file name (string) starting with PREFIX (a string).
837 The Emacs process number forms part of the result, 824 The Emacs process number forms part of the result,
838 so there is no danger of generating a name being used by another process. 825 so there is no danger of generating a name being used by another process.
839 */ ) 826 */
840 (prefix) 827 (prefix))
841 Lisp_Object prefix;
842 { 828 {
843 CONST char suffix[] = "XXXXXX"; 829 CONST char suffix[] = "XXXXXX";
844 Bufbyte *data; 830 Bufbyte *data;
845 Bytecount len; 831 Bytecount len;
846 Lisp_Object val; 832 Lisp_Object val;
855 mktemp ((char *) data); 841 mktemp ((char *) data);
856 842
857 return val; 843 return val;
858 } 844 }
859 845
860 DEFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0 /* 846 DEFUN ("expand-file-name", Fexpand_file_name, 1, 2, 0, /*
861 Convert FILENAME to absolute, and canonicalize it. 847 Convert FILENAME to absolute, and canonicalize it.
862 Second arg DEFAULT is directory to start with if FILENAME is relative 848 Second arg DEFAULT is directory to start with if FILENAME is relative
863 (does not start with slash); if DEFAULT is nil or missing, 849 (does not start with slash); if DEFAULT is nil or missing,
864 the current buffer's value of default-directory is used. 850 the current buffer's value of default-directory is used.
865 Path components that are `.' are removed, and 851 Path components that are `.' are removed, and
867 note that these simplifications are done without checking the resulting 853 note that these simplifications are done without checking the resulting
868 paths in the file system. 854 paths in the file system.
869 An initial `~/' expands to your home directory. 855 An initial `~/' expands to your home directory.
870 An initial `~USER/' expands to USER's home directory. 856 An initial `~USER/' expands to USER's home directory.
871 See also the function `substitute-in-file-name'. 857 See also the function `substitute-in-file-name'.
872 */ ) 858 */
873 (name, defalt) 859 (name, defalt))
874 Lisp_Object name, defalt;
875 { 860 {
876 /* This function can GC */ 861 /* This function can GC */
877 Bufbyte *nm; 862 Bufbyte *nm;
878 863
879 Bufbyte *newdir, *p, *o; 864 Bufbyte *newdir, *p, *o;
1384 1369
1385 /* not a full declaration because realpath() is typed differently 1370 /* not a full declaration because realpath() is typed differently
1386 on different systems */ 1371 on different systems */
1387 extern char *realpath (); 1372 extern char *realpath ();
1388 1373
1389 DEFUN ("file-truename", Ffile_truename, Sfile_truename, 1, 2, 0 /* 1374 DEFUN ("file-truename", Ffile_truename, 1, 2, 0, /*
1390 Return the canonical name of the given FILE. 1375 Return the canonical name of the given FILE.
1391 Second arg DEFAULT is directory to start with if FILE is relative 1376 Second arg DEFAULT is directory to start with if FILE is relative
1392 (does not start with slash); if DEFAULT is nil or missing, 1377 (does not start with slash); if DEFAULT is nil or missing,
1393 the current buffer's value of default-directory is used. 1378 the current buffer's value of default-directory is used.
1394 No component of the resulting pathname will be a symbolic link, as 1379 No component of the resulting pathname will be a symbolic link, as
1395 in the realpath() function. 1380 in the realpath() function.
1396 */ ) 1381 */
1397 (filename, defalt) 1382 (filename, defalt))
1398 Lisp_Object filename, defalt;
1399 { 1383 {
1400 /* This function can GC */ 1384 /* This function can GC */
1401 struct gcpro gcpro1; 1385 struct gcpro gcpro1;
1402 Lisp_Object expanded_name; 1386 Lisp_Object expanded_name;
1403 Lisp_Object handler; 1387 Lisp_Object handler;
1511 return Qnil; /* suppress compiler warning */ 1495 return Qnil; /* suppress compiler warning */
1512 #endif /* not VMS */ 1496 #endif /* not VMS */
1513 } 1497 }
1514 1498
1515 1499
1516 DEFUN ("substitute-in-file-name", Fsubstitute_in_file_name, 1500 DEFUN ("substitute-in-file-name", Fsubstitute_in_file_name, 1, 1, 0, /*
1517 Ssubstitute_in_file_name, 1, 1, 0 /*
1518 Substitute environment variables referred to in FILENAME. 1501 Substitute environment variables referred to in FILENAME.
1519 `$FOO' where FOO is an environment variable name means to substitute 1502 `$FOO' where FOO is an environment variable name means to substitute
1520 the value of that variable. The variable name should be terminated 1503 the value of that variable. The variable name should be terminated
1521 with a character not a letter, digit or underscore; otherwise, enclose 1504 with a character not a letter, digit or underscore; otherwise, enclose
1522 the entire variable name in braces. 1505 the entire variable name in braces.
1523 If `/~' appears, all of FILENAME through that `/' is discarded. 1506 If `/~' appears, all of FILENAME through that `/' is discarded.
1524 1507
1525 On VMS, `$' substitution is not done; this function does little and only 1508 On VMS, `$' substitution is not done; this function does little and only
1526 duplicates what `expand-file-name' does. 1509 duplicates what `expand-file-name' does.
1527 */ ) 1510 */
1528 (string) 1511 (string))
1529 Lisp_Object string;
1530 { 1512 {
1531 Bufbyte *nm; 1513 Bufbyte *nm;
1532 1514
1533 Bufbyte *s, *p, *o, *x, *endp; 1515 Bufbyte *s, *p, *o, *x, *endp;
1534 Bufbyte *target = 0; 1516 Bufbyte *target = 0;
1815 statptr->st_mode = 0; 1797 statptr->st_mode = 0;
1816 } 1798 }
1817 return; 1799 return;
1818 } 1800 }
1819 1801
1820 DEFUN ("copy-file", Fcopy_file, Scopy_file, 2, 4, 1802 DEFUN ("copy-file", Fcopy_file, 2, 4,
1821 "fCopy file: \nFCopy %s to file: \np\nP" /* 1803 "fCopy file: \nFCopy %s to file: \np\nP", /*
1822 Copy FILE to NEWNAME. Both args must be strings. 1804 Copy FILE to NEWNAME. Both args must be strings.
1823 Signals a `file-already-exists' error if file NEWNAME already exists, 1805 Signals a `file-already-exists' error if file NEWNAME already exists,
1824 unless a third argument OK-IF-ALREADY-EXISTS is supplied and non-nil. 1806 unless a third argument OK-IF-ALREADY-EXISTS is supplied and non-nil.
1825 A number as third arg means request confirmation if NEWNAME already exists. 1807 A number as third arg means request confirmation if NEWNAME already exists.
1826 This is what happens in interactive use with M-x. 1808 This is what happens in interactive use with M-x.
1827 Fourth arg KEEP-TIME non-nil means give the new file the same 1809 Fourth arg KEEP-TIME non-nil means give the new file the same
1828 last-modified time as the old one. (This works on only some systems.) 1810 last-modified time as the old one. (This works on only some systems.)
1829 A prefix arg makes KEEP-TIME non-nil. 1811 A prefix arg makes KEEP-TIME non-nil.
1830 */ ) 1812 */
1831 (filename, newname, ok_if_already_exists, keep_time) 1813 (filename, newname, ok_if_already_exists, keep_time))
1832 Lisp_Object filename, newname, ok_if_already_exists, keep_time;
1833 { 1814 {
1834 /* This function can GC */ 1815 /* This function can GC */
1835 int ifd, ofd, n; 1816 int ifd, ofd, n;
1836 char buf[16 * 1024]; 1817 char buf[16 * 1024];
1837 struct stat st, out_st; 1818 struct stat st, out_st;
1990 1971
1991 UNGCPRO; 1972 UNGCPRO;
1992 return Qnil; 1973 return Qnil;
1993 } 1974 }
1994 1975
1995 DEFUN ("make-directory-internal", Fmake_directory_internal, 1976 DEFUN ("make-directory-internal", Fmake_directory_internal, 1, 1, 0, /*
1996 Smake_directory_internal, 1, 1, 0 /*
1997 Create a directory. One argument, a file name string. 1977 Create a directory. One argument, a file name string.
1998 */ ) 1978 */
1999 (dirname) 1979 (dirname))
2000 Lisp_Object dirname;
2001 { 1980 {
2002 /* This function can GC */ 1981 /* This function can GC */
2003 char dir [MAXPATHLEN]; 1982 char dir [MAXPATHLEN];
2004 Lisp_Object handler; 1983 Lisp_Object handler;
2005 1984
2038 report_file_error ("Creating directory", list1 (dirname)); 2017 report_file_error ("Creating directory", list1 (dirname));
2039 2018
2040 return Qnil; 2019 return Qnil;
2041 } 2020 }
2042 2021
2043 DEFUN ("delete-directory", Fdelete_directory, Sdelete_directory, 1, 1, 2022 DEFUN ("delete-directory", Fdelete_directory, 1, 1, "FDelete directory: ", /*
2044 "FDelete directory: " /*
2045 Delete a directory. One argument, a file name or directory name string. 2023 Delete a directory. One argument, a file name or directory name string.
2046 */ ) 2024 */
2047 (dirname) 2025 (dirname))
2048 Lisp_Object dirname;
2049 { 2026 {
2050 /* This function can GC */ 2027 /* This function can GC */
2051 Lisp_Object handler; 2028 Lisp_Object handler;
2052 struct gcpro gcpro1; 2029 struct gcpro gcpro1;
2053 2030
2065 report_file_error ("Removing directory", list1 (dirname)); 2042 report_file_error ("Removing directory", list1 (dirname));
2066 2043
2067 return Qnil; 2044 return Qnil;
2068 } 2045 }
2069 2046
2070 DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 1, "fDelete file: " /* 2047 DEFUN ("delete-file", Fdelete_file, 1, 1, "fDelete file: ", /*
2071 Delete specified file. One argument, a file name string. 2048 Delete specified file. One argument, a file name string.
2072 If file has multiple names, it continues to exist with the other names. 2049 If file has multiple names, it continues to exist with the other names.
2073 */ ) 2050 */
2074 (filename) 2051 (filename))
2075 Lisp_Object filename;
2076 { 2052 {
2077 /* This function can GC */ 2053 /* This function can GC */
2078 Lisp_Object handler; 2054 Lisp_Object handler;
2079 struct gcpro gcpro1; 2055 struct gcpro gcpro1;
2080 2056
2105 { 2081 {
2106 return NILP (condition_case_1 (Qt, Fdelete_file, filename, 2082 return NILP (condition_case_1 (Qt, Fdelete_file, filename,
2107 internal_delete_file_1, Qnil)); 2083 internal_delete_file_1, Qnil));
2108 } 2084 }
2109 2085
2110 DEFUN ("rename-file", Frename_file, Srename_file, 2, 3, 2086 DEFUN ("rename-file", Frename_file, 2, 3,
2111 "fRename file: \nFRename %s to file: \np" /* 2087 "fRename file: \nFRename %s to file: \np", /*
2112 Rename FILE as NEWNAME. Both args strings. 2088 Rename FILE as NEWNAME. Both args strings.
2113 If file has names other than FILE, it continues to have those names. 2089 If file has names other than FILE, it continues to have those names.
2114 Signals a `file-already-exists' error if a file NEWNAME already exists 2090 Signals a `file-already-exists' error if a file NEWNAME already exists
2115 unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. 2091 unless optional third argument OK-IF-ALREADY-EXISTS is non-nil.
2116 A number as third arg means request confirmation if NEWNAME already exists. 2092 A number as third arg means request confirmation if NEWNAME already exists.
2117 This is what happens in interactive use with M-x. 2093 This is what happens in interactive use with M-x.
2118 */ ) 2094 */
2119 (filename, newname, ok_if_already_exists) 2095 (filename, newname, ok_if_already_exists))
2120 Lisp_Object filename, newname, ok_if_already_exists;
2121 { 2096 {
2122 /* This function can GC */ 2097 /* This function can GC */
2123 Lisp_Object handler; 2098 Lisp_Object handler;
2124 struct gcpro gcpro1, gcpro2; 2099 struct gcpro gcpro1, gcpro2;
2125 2100
2200 } 2175 }
2201 UNGCPRO; 2176 UNGCPRO;
2202 return Qnil; 2177 return Qnil;
2203 } 2178 }
2204 2179
2205 DEFUN ("add-name-to-file", Fadd_name_to_file, Sadd_name_to_file, 2, 3, 2180 DEFUN ("add-name-to-file", Fadd_name_to_file, 2, 3,
2206 "fAdd name to file: \nFName to add to %s: \np" /* 2181 "fAdd name to file: \nFName to add to %s: \np", /*
2207 Give FILE additional name NEWNAME. Both args strings. 2182 Give FILE additional name NEWNAME. Both args strings.
2208 Signals a `file-already-exists' error if a file NEWNAME already exists 2183 Signals a `file-already-exists' error if a file NEWNAME already exists
2209 unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. 2184 unless optional third argument OK-IF-ALREADY-EXISTS is non-nil.
2210 A number as third arg means request confirmation if NEWNAME already exists. 2185 A number as third arg means request confirmation if NEWNAME already exists.
2211 This is what happens in interactive use with M-x. 2186 This is what happens in interactive use with M-x.
2212 */ ) 2187 */
2213 (filename, newname, ok_if_already_exists) 2188 (filename, newname, ok_if_already_exists))
2214 Lisp_Object filename, newname, ok_if_already_exists;
2215 { 2189 {
2216 /* This function can GC */ 2190 /* This function can GC */
2217 Lisp_Object handler; 2191 Lisp_Object handler;
2218 struct gcpro gcpro1, gcpro2; 2192 struct gcpro gcpro1, gcpro2;
2219 2193
2258 UNGCPRO; 2232 UNGCPRO;
2259 return Qnil; 2233 return Qnil;
2260 } 2234 }
2261 2235
2262 #ifdef S_IFLNK 2236 #ifdef S_IFLNK
2263 DEFUN ("make-symbolic-link", Fmake_symbolic_link, Smake_symbolic_link, 2, 3, 2237 DEFUN ("make-symbolic-link", Fmake_symbolic_link, 2, 3,
2264 "FMake symbolic link to file: \nFMake symbolic link to file %s: \np" /* 2238 "FMake symbolic link to file: \nFMake symbolic link to file %s: \np", /*
2265 Make a symbolic link to FILENAME, named LINKNAME. Both args strings. 2239 Make a symbolic link to FILENAME, named LINKNAME. Both args strings.
2266 Signals a `file-already-exists' error if a file LINKNAME already exists 2240 Signals a `file-already-exists' error if a file LINKNAME already exists
2267 unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. 2241 unless optional third argument OK-IF-ALREADY-EXISTS is non-nil.
2268 A number as third arg means request confirmation if LINKNAME already exists. 2242 A number as third arg means request confirmation if LINKNAME already exists.
2269 This happens for interactive use with M-x. 2243 This happens for interactive use with M-x.
2270 */ ) 2244 */
2271 (filename, linkname, ok_if_already_exists) 2245 (filename, linkname, ok_if_already_exists))
2272 Lisp_Object filename, linkname, ok_if_already_exists;
2273 { 2246 {
2274 /* This function can GC */ 2247 /* This function can GC */
2275 Lisp_Object handler; 2248 Lisp_Object handler;
2276 struct gcpro gcpro1, gcpro2; 2249 struct gcpro gcpro1, gcpro2;
2277 2250
2316 } 2289 }
2317 #endif /* S_IFLNK */ 2290 #endif /* S_IFLNK */
2318 2291
2319 #ifdef VMS 2292 #ifdef VMS
2320 2293
2321 DEFUN ("define-logical-name", Fdefine_logical_name, Sdefine_logical_name, 2294 DEFUN ("define-logical-name", Fdefine_logical_name, 2, 2,
2322 2, 2, "sDefine logical name: \nsDefine logical name %s as: " /* 2295 "sDefine logical name: \nsDefine logical name %s as: ", /*
2323 Define the job-wide logical name NAME to have the value STRING. 2296 Define the job-wide logical name NAME to have the value STRING.
2324 If STRING is nil or a null string, the logical name NAME is deleted. 2297 If STRING is nil or a null string, the logical name NAME is deleted.
2325 */ ) 2298 */
2326 (varname, string) 2299 (varname, string))
2327 Lisp_Object varname;
2328 Lisp_Object string;
2329 { 2300 {
2330 CHECK_STRING (varname); 2301 CHECK_STRING (varname);
2331 if (NILP (string)) 2302 if (NILP (string))
2332 delete_logical_name ((char *) XSTRING_DATA (varname)); 2303 delete_logical_name ((char *) XSTRING_DATA (varname));
2333 else 2304 else
2344 } 2315 }
2345 #endif /* VMS */ 2316 #endif /* VMS */
2346 2317
2347 #ifdef HPUX_NET 2318 #ifdef HPUX_NET
2348 2319
2349 DEFUN ("sysnetunam", Fsysnetunam, Ssysnetunam, 2, 2, 0 /* 2320 DEFUN ("sysnetunam", Fsysnetunam, 2, 2, 0, /*
2350 Open a network connection to PATH using LOGIN as the login string. 2321 Open a network connection to PATH using LOGIN as the login string.
2351 */ ) 2322 */
2352 (path, login) 2323 (path, login))
2353 Lisp_Object path, login;
2354 { 2324 {
2355 int netresult; 2325 int netresult;
2356 2326
2357 CHECK_STRING (path); 2327 CHECK_STRING (path);
2358 CHECK_STRING (login); 2328 CHECK_STRING (login);
2374 else 2344 else
2375 return Qt; 2345 return Qt;
2376 } 2346 }
2377 #endif /* HPUX_NET */ 2347 #endif /* HPUX_NET */
2378 2348
2379 DEFUN ("file-name-absolute-p", Ffile_name_absolute_p, Sfile_name_absolute_p, 2349 DEFUN ("file-name-absolute-p", Ffile_name_absolute_p, 1, 1, 0, /*
2380 1, 1, 0 /*
2381 Return t if file FILENAME specifies an absolute path name. 2350 Return t if file FILENAME specifies an absolute path name.
2382 On Unix, this is a name starting with a `/' or a `~'. 2351 On Unix, this is a name starting with a `/' or a `~'.
2383 */ ) 2352 */
2384 (filename) 2353 (filename))
2385 Lisp_Object filename;
2386 { 2354 {
2387 Bufbyte *ptr; 2355 Bufbyte *ptr;
2388 2356
2389 CHECK_STRING (filename); 2357 CHECK_STRING (filename);
2390 ptr = XSTRING_DATA (filename); 2358 ptr = XSTRING_DATA (filename);
2455 return (access (filename, 2) >= 0); 2423 return (access (filename, 2) >= 0);
2456 #endif 2424 #endif
2457 #endif /* not MSDOS */ 2425 #endif /* not MSDOS */
2458 } 2426 }
2459 2427
2460 DEFUN ("file-exists-p", Ffile_exists_p, Sfile_exists_p, 1, 1, 0 /* 2428 DEFUN ("file-exists-p", Ffile_exists_p, 1, 1, 0, /*
2461 Return t if file FILENAME exists. (This does not mean you can read it.) 2429 Return t if file FILENAME exists. (This does not mean you can read it.)
2462 See also `file-readable-p' and `file-attributes'. 2430 See also `file-readable-p' and `file-attributes'.
2463 */ ) 2431 */
2464 (filename) 2432 (filename))
2465 Lisp_Object filename;
2466 { 2433 {
2467 /* This function can GC */ 2434 /* This function can GC */
2468 Lisp_Object abspath; 2435 Lisp_Object abspath;
2469 Lisp_Object handler; 2436 Lisp_Object handler;
2470 struct stat statbuf; 2437 struct stat statbuf;
2487 return (Qt); 2454 return (Qt);
2488 else 2455 else
2489 return (Qnil); 2456 return (Qnil);
2490 } 2457 }
2491 2458
2492 DEFUN ("file-executable-p", Ffile_executable_p, Sfile_executable_p, 1, 1, 0 /* 2459 DEFUN ("file-executable-p", Ffile_executable_p, 1, 1, 0, /*
2493 Return t if FILENAME can be executed by you. 2460 Return t if FILENAME can be executed by you.
2494 For a directory, this means you can access files in that directory. 2461 For a directory, this means you can access files in that directory.
2495 */ ) 2462 */
2496 (filename) 2463 (filename))
2497 Lisp_Object filename;
2498
2499 { 2464 {
2500 /* This function can GC */ 2465 /* This function can GC */
2501 Lisp_Object abspath; 2466 Lisp_Object abspath;
2502 Lisp_Object handler; 2467 Lisp_Object handler;
2503 struct gcpro gcpro1; 2468 struct gcpro gcpro1;
2517 2482
2518 return (check_executable ((char *) XSTRING_DATA (abspath)) 2483 return (check_executable ((char *) XSTRING_DATA (abspath))
2519 ? Qt : Qnil); 2484 ? Qt : Qnil);
2520 } 2485 }
2521 2486
2522 DEFUN ("file-readable-p", Ffile_readable_p, Sfile_readable_p, 1, 1, 0 /* 2487 DEFUN ("file-readable-p", Ffile_readable_p, 1, 1, 0, /*
2523 Return t if file FILENAME exists and you can read it. 2488 Return t if file FILENAME exists and you can read it.
2524 See also `file-exists-p' and `file-attributes'. 2489 See also `file-exists-p' and `file-attributes'.
2525 */ ) 2490 */
2526 (filename) 2491 (filename))
2527 Lisp_Object filename;
2528 { 2492 {
2529 /* This function can GC */ 2493 /* This function can GC */
2530 Lisp_Object abspath; 2494 Lisp_Object abspath;
2531 Lisp_Object handler; 2495 Lisp_Object handler;
2532 int desc; 2496 int desc;
2552 return Qt; 2516 return Qt;
2553 } 2517 }
2554 2518
2555 /* Having this before file-symlink-p mysteriously caused it to be forgotten 2519 /* Having this before file-symlink-p mysteriously caused it to be forgotten
2556 on the RT/PC. */ 2520 on the RT/PC. */
2557 DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0 /* 2521 DEFUN ("file-writable-p", Ffile_writable_p, 1, 1, 0, /*
2558 Return t if file FILENAME can be written or created by you. 2522 Return t if file FILENAME can be written or created by you.
2559 */ ) 2523 */
2560 (filename) 2524 (filename))
2561 Lisp_Object filename;
2562 { 2525 {
2563 /* This function can GC */ 2526 /* This function can GC */
2564 Lisp_Object abspath, dir; 2527 Lisp_Object abspath, dir;
2565 Lisp_Object handler; 2528 Lisp_Object handler;
2566 struct stat statbuf; 2529 struct stat statbuf;
2592 return (check_writable (!NILP (dir) ? (char *) XSTRING_DATA (dir) 2555 return (check_writable (!NILP (dir) ? (char *) XSTRING_DATA (dir)
2593 : "") 2556 : "")
2594 ? Qt : Qnil); 2557 ? Qt : Qnil);
2595 } 2558 }
2596 2559
2597 DEFUN ("file-symlink-p", Ffile_symlink_p, Sfile_symlink_p, 1, 1, 0 /* 2560 DEFUN ("file-symlink-p", Ffile_symlink_p, 1, 1, 0, /*
2598 Return non-nil if file FILENAME is the name of a symbolic link. 2561 Return non-nil if file FILENAME is the name of a symbolic link.
2599 The value is the name of the file to which it is linked. 2562 The value is the name of the file to which it is linked.
2600 Otherwise returns nil. 2563 Otherwise returns nil.
2601 */ ) 2564 */
2602 (filename) 2565 (filename))
2603 Lisp_Object filename;
2604 { 2566 {
2605 /* This function can GC */ 2567 /* This function can GC */
2606 #ifdef S_IFLNK 2568 #ifdef S_IFLNK
2607 char *buf; 2569 char *buf;
2608 int bufsize; 2570 int bufsize;
2645 #else /* not S_IFLNK */ 2607 #else /* not S_IFLNK */
2646 return Qnil; 2608 return Qnil;
2647 #endif /* not S_IFLNK */ 2609 #endif /* not S_IFLNK */
2648 } 2610 }
2649 2611
2650 DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0 /* 2612 DEFUN ("file-directory-p", Ffile_directory_p, 1, 1, 0, /*
2651 Return t if file FILENAME is the name of a directory as a file. 2613 Return t if file FILENAME is the name of a directory as a file.
2652 A directory name spec may be given instead; then the value is t 2614 A directory name spec may be given instead; then the value is t
2653 if the directory so specified exists and really is a directory. 2615 if the directory so specified exists and really is a directory.
2654 */ ) 2616 */
2655 (filename) 2617 (filename))
2656 Lisp_Object filename;
2657 { 2618 {
2658 /* This function can GC */ 2619 /* This function can GC */
2659 Lisp_Object abspath; 2620 Lisp_Object abspath;
2660 struct stat st; 2621 struct stat st;
2661 Lisp_Object handler; 2622 Lisp_Object handler;
2677 if (stat ((char *) XSTRING_DATA (abspath), &st) < 0) 2638 if (stat ((char *) XSTRING_DATA (abspath), &st) < 0)
2678 return Qnil; 2639 return Qnil;
2679 return (st.st_mode & S_IFMT) == S_IFDIR ? Qt : Qnil; 2640 return (st.st_mode & S_IFMT) == S_IFDIR ? Qt : Qnil;
2680 } 2641 }
2681 2642
2682 DEFUN ("file-accessible-directory-p", 2643 DEFUN ("file-accessible-directory-p", Ffile_accessible_directory_p, 1, 1, 0, /*
2683 Ffile_accessible_directory_p, Sfile_accessible_directory_p, 1, 1, 0 /*
2684 Return t if file FILENAME is the name of a directory as a file, 2644 Return t if file FILENAME is the name of a directory as a file,
2685 and files in that directory can be opened by you. In order to use a 2645 and files in that directory can be opened by you. In order to use a
2686 directory as a buffer's current directory, this predicate must return true. 2646 directory as a buffer's current directory, this predicate must return true.
2687 A directory name spec may be given instead; then the value is t 2647 A directory name spec may be given instead; then the value is t
2688 if the directory so specified exists and really is a readable and 2648 if the directory so specified exists and really is a readable and
2689 searchable directory. 2649 searchable directory.
2690 */ ) 2650 */
2691 (filename) 2651 (filename))
2692 Lisp_Object filename;
2693 { 2652 {
2694 /* This function can GC */ 2653 /* This function can GC */
2695 Lisp_Object handler; 2654 Lisp_Object handler;
2696 struct gcpro gcpro1; 2655 struct gcpro gcpro1;
2697 2656
2711 handler = Ffile_executable_p (filename); 2670 handler = Ffile_executable_p (filename);
2712 UNGCPRO; 2671 UNGCPRO;
2713 return (handler); 2672 return (handler);
2714 } 2673 }
2715 2674
2716 DEFUN ("file-regular-p", Ffile_regular_p, Sfile_regular_p, 1, 1, 0 /* 2675 DEFUN ("file-regular-p", Ffile_regular_p, 1, 1, 0, /*
2717 "Return t if file FILENAME is the name of a regular file. 2676 "Return t if file FILENAME is the name of a regular file.
2718 This is the sort of file that holds an ordinary stream of data bytes. 2677 This is the sort of file that holds an ordinary stream of data bytes.
2719 */ ) 2678 */
2720 (filename) 2679 (filename))
2721 Lisp_Object filename;
2722 { 2680 {
2723 REGISTER Lisp_Object abspath; 2681 REGISTER Lisp_Object abspath;
2724 struct stat st; 2682 struct stat st;
2725 Lisp_Object handler; 2683 Lisp_Object handler;
2726 2684
2735 if (stat ((char *) XSTRING_DATA (abspath), &st) < 0) 2693 if (stat ((char *) XSTRING_DATA (abspath), &st) < 0)
2736 return Qnil; 2694 return Qnil;
2737 return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil; 2695 return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil;
2738 } 2696 }
2739 2697
2740 DEFUN ("file-modes", Ffile_modes, Sfile_modes, 1, 1, 0 /* 2698 DEFUN ("file-modes", Ffile_modes, 1, 1, 0, /*
2741 Return mode bits of FILE, as an integer. 2699 Return mode bits of FILE, as an integer.
2742 */ ) 2700 */
2743 (filename) 2701 (filename))
2744 Lisp_Object filename;
2745 { 2702 {
2746 /* This function can GC */ 2703 /* This function can GC */
2747 Lisp_Object abspath; 2704 Lisp_Object abspath;
2748 struct stat st; 2705 struct stat st;
2749 Lisp_Object handler; 2706 Lisp_Object handler;
2770 #endif /* DOS_NT */ 2727 #endif /* DOS_NT */
2771 2728
2772 return make_int (st.st_mode & 07777); 2729 return make_int (st.st_mode & 07777);
2773 } 2730 }
2774 2731
2775 DEFUN ("set-file-modes", Fset_file_modes, Sset_file_modes, 2, 2, 0 /* 2732 DEFUN ("set-file-modes", Fset_file_modes, 2, 2, 0, /*
2776 Set mode bits of FILE to MODE (an integer). 2733 Set mode bits of FILE to MODE (an integer).
2777 Only the 12 low bits of MODE are used. 2734 Only the 12 low bits of MODE are used.
2778 */ ) 2735 */
2779 (filename, mode) 2736 (filename, mode))
2780 Lisp_Object filename, mode;
2781 { 2737 {
2782 /* This function can GC */ 2738 /* This function can GC */
2783 Lisp_Object abspath; 2739 Lisp_Object abspath;
2784 Lisp_Object handler; 2740 Lisp_Object handler;
2785 struct gcpro gcpro1, gcpro2; 2741 struct gcpro gcpro1, gcpro2;
2801 report_file_error ("Doing chmod", Fcons (abspath, Qnil)); 2757 report_file_error ("Doing chmod", Fcons (abspath, Qnil));
2802 2758
2803 return Qnil; 2759 return Qnil;
2804 } 2760 }
2805 2761
2806 DEFUN ("set-default-file-modes", Fset_default_file_modes, 2762 DEFUN ("set-default-file-modes", Fset_default_file_modes, 1, 1, 0, /*
2807 Sset_default_file_modes, 1, 1, 0 /*
2808 Set the file permission bits for newly created files. 2763 Set the file permission bits for newly created files.
2809 MASK should be an integer; if a permission's bit in MASK is 1, 2764 MASK should be an integer; if a permission's bit in MASK is 1,
2810 subsequently created files will not have that permission enabled. 2765 subsequently created files will not have that permission enabled.
2811 Only the low 9 bits are used. 2766 Only the low 9 bits are used.
2812 This setting is inherited by subprocesses. 2767 This setting is inherited by subprocesses.
2813 */ ) 2768 */
2814 (mode) 2769 (mode))
2815 Lisp_Object mode;
2816 { 2770 {
2817 CHECK_INT (mode); 2771 CHECK_INT (mode);
2818 2772
2819 umask ((~ XINT (mode)) & 0777); 2773 umask ((~ XINT (mode)) & 0777);
2820 2774
2821 return Qnil; 2775 return Qnil;
2822 } 2776 }
2823 2777
2824 DEFUN ("default-file-modes", Fdefault_file_modes, Sdefault_file_modes, 0, 0, 0 /* 2778 DEFUN ("default-file-modes", Fdefault_file_modes, 0, 0, 0, /*
2825 Return the default file protection for created files. 2779 Return the default file protection for created files.
2826 The umask value determines which permissions are enabled in newly 2780 The umask value determines which permissions are enabled in newly
2827 created files. If a permission's bit in the umask is 1, subsequently 2781 created files. If a permission's bit in the umask is 1, subsequently
2828 created files will not have that permission enabled. 2782 created files will not have that permission enabled.
2829 */ ) 2783 */
2830 () 2784 ())
2831 { 2785 {
2832 int mode; 2786 int mode;
2833 2787
2834 mode = umask (0); 2788 mode = umask (0);
2835 umask (mode); 2789 umask (mode);
2836 2790
2837 return make_int ((~ mode) & 0777); 2791 return make_int ((~ mode) & 0777);
2838 } 2792 }
2839 2793
2840 #ifndef VMS 2794 #ifndef VMS
2841 DEFUN ("unix-sync", Funix_sync, Sunix_sync, 0, 0, "" /* 2795 DEFUN ("unix-sync", Funix_sync, 0, 0, "", /*
2842 Tell Unix to finish all pending disk updates. 2796 Tell Unix to finish all pending disk updates.
2843 */ ) 2797 */
2844 () 2798 ())
2845 { 2799 {
2846 sync (); 2800 sync ();
2847 return Qnil; 2801 return Qnil;
2848 } 2802 }
2849 #endif /* !VMS */ 2803 #endif /* !VMS */
2850 2804
2851 2805
2852 DEFUN ("file-newer-than-file-p", Ffile_newer_than_file_p, 2806 DEFUN ("file-newer-than-file-p", Ffile_newer_than_file_p, 2, 2, 0, /*
2853 Sfile_newer_than_file_p, 2, 2, 0 /*
2854 Return t if file FILE1 is newer than file FILE2. 2807 Return t if file FILE1 is newer than file FILE2.
2855 If FILE1 does not exist, the answer is nil; 2808 If FILE1 does not exist, the answer is nil;
2856 otherwise, if FILE2 does not exist, the answer is t. 2809 otherwise, if FILE2 does not exist, the answer is t.
2857 */ ) 2810 */
2858 (file1, file2) 2811 (file1, file2))
2859 Lisp_Object file1, file2;
2860 { 2812 {
2861 /* This function can GC */ 2813 /* This function can GC */
2862 Lisp_Object abspath1, abspath2; 2814 Lisp_Object abspath1, abspath2;
2863 struct stat st; 2815 struct stat st;
2864 int mtime1; 2816 int mtime1;
2905 2857
2906 /* Stack sizes > 2**16 is a good way to elicit compiler bugs */ 2858 /* Stack sizes > 2**16 is a good way to elicit compiler bugs */
2907 /* #define READ_BUF_SIZE (2 << 16) */ 2859 /* #define READ_BUF_SIZE (2 << 16) */
2908 #define READ_BUF_SIZE (1 << 15) 2860 #define READ_BUF_SIZE (1 << 15)
2909 2861
2910 DEFUN ("insert-file-contents-internal", Finsert_file_contents_internal, 2862 DEFUN ("insert-file-contents-internal",
2911 Sinsert_file_contents_internal, 1, 5, 0 /* 2863 Finsert_file_contents_internal, 1, 5, 0, /*
2912 Insert contents of file FILENAME after point. 2864 Insert contents of file FILENAME after point.
2913 Returns list of absolute file name and length of data inserted. 2865 Returns list of absolute file name and length of data inserted.
2914 If second argument VISIT is non-nil, the buffer's visited filename 2866 If second argument VISIT is non-nil, the buffer's visited filename
2915 and last save file modtime are set, and it is marked unmodified. 2867 and last save file modtime are set, and it is marked unmodified.
2916 If visiting and the file does not exist, visiting is completed 2868 If visiting and the file does not exist, visiting is completed
2922 If optional fifth argument REPLACE is non-nil, 2874 If optional fifth argument REPLACE is non-nil,
2923 it means replace the current buffer contents (in the accessible portion) 2875 it means replace the current buffer contents (in the accessible portion)
2924 with the file contents. This is better than simply deleting and inserting 2876 with the file contents. This is better than simply deleting and inserting
2925 the whole thing because (1) it preserves some marker positions 2877 the whole thing because (1) it preserves some marker positions
2926 and (2) it puts less data in the undo list. 2878 and (2) it puts less data in the undo list.
2927 */ ) 2879 */
2928 (filename, visit, beg, end, replace) 2880 (filename, visit, beg, end, replace))
2929 Lisp_Object filename, visit, beg, end, replace;
2930 { 2881 {
2931 /* This function can GC */ 2882 /* This function can GC */
2932 struct stat st; 2883 struct stat st;
2933 int fd; 2884 int fd;
2934 int saverrno = 0; 2885 int saverrno = 0;
3049 that preserves markers pointing to the unchanged parts. */ 3000 that preserves markers pointing to the unchanged parts. */
3050 #if !defined (DOS_NT) && !defined (MULE) 3001 #if !defined (DOS_NT) && !defined (MULE)
3051 /* The replace-mode code currently only works when the assumption 3002 /* The replace-mode code currently only works when the assumption
3052 'one byte == one char' holds true. This fails under MSDOS and 3003 'one byte == one char' holds true. This fails under MSDOS and
3053 Windows NT (because newlines are represented as CR-LF in text 3004 Windows NT (because newlines are represented as CR-LF in text
3054 files). and under Mule because files may contain multibyte characters. */ 3005 files) and under Mule because files may contain multibyte characters. */
3055 # define FSFMACS_SPEEDY_INSERT 3006 # define FSFMACS_SPEEDY_INSERT
3056 #endif 3007 #endif
3057 #ifndef FSFMACS_SPEEDY_INSERT 3008 #ifndef FSFMACS_SPEEDY_INSERT
3058 if (!NILP (replace)) 3009 if (!NILP (replace))
3059 { 3010 {
3350 Fset_buffer (buf); 3301 Fset_buffer (buf);
3351 Fkill_buffer (tembuf); 3302 Fkill_buffer (tembuf);
3352 return Qnil; 3303 return Qnil;
3353 } 3304 }
3354 3305
3355 DEFUN ("write-region-internal", Fwrite_region_internal, 3306 DEFUN ("write-region-internal", Fwrite_region_internal, 3, 6,
3356 Swrite_region_internal, 3, 6, 3307 "r\nFWrite region to file: ", /*
3357 "r\nFWrite region to file: " /*
3358 Write current region into specified file. 3308 Write current region into specified file.
3359 When called from a program, takes three arguments: 3309 When called from a program, takes three arguments:
3360 START, END and FILENAME. START and END are buffer positions. 3310 START, END and FILENAME. START and END are buffer positions.
3361 Optional fourth argument APPEND if non-nil means 3311 Optional fourth argument APPEND if non-nil means
3362 append to existing file contents (if any). 3312 append to existing file contents (if any).
3368 VISIT is also the file name to lock and unlock for clash detection. 3318 VISIT is also the file name to lock and unlock for clash detection.
3369 If VISIT is neither t nor nil nor a string, 3319 If VISIT is neither t nor nil nor a string,
3370 that means do not print the \"Wrote file\" message. 3320 that means do not print the \"Wrote file\" message.
3371 Kludgy feature: if START is a string, then that string is written 3321 Kludgy feature: if START is a string, then that string is written
3372 to the file, instead of any buffer contents, and END is ignored. 3322 to the file, instead of any buffer contents, and END is ignored.
3373 */ ) 3323 */
3374 (start, end, filename, append, visit, lockname) 3324 (start, end, filename, append, visit, lockname))
3375 Lisp_Object start, end, filename, append, visit, lockname;
3376 { 3325 {
3377 /* This function can GC */ 3326 /* This function can GC */
3378 int desc; 3327 int desc;
3379 int failure; 3328 int failure;
3380 int save_errno = 0; 3329 int save_errno = 0;
3763 } 3712 }
3764 3713
3765 /* #### This is such a load of shit!!!! There is no way we should define 3714 /* #### This is such a load of shit!!!! There is no way we should define
3766 something so stupid as a subr, just sort the fucking list more 3715 something so stupid as a subr, just sort the fucking list more
3767 intelligently. */ 3716 intelligently. */
3768 DEFUN ("car-less-than-car", Fcar_less_than_car, Scar_less_than_car, 2, 2, 0 /* 3717 DEFUN ("car-less-than-car", Fcar_less_than_car, 2, 2, 0, /*
3769 Return t if (car A) is numerically less than (car B). 3718 Return t if (car A) is numerically less than (car B).
3770 */ ) 3719 */
3771 (a, b) 3720 (a, b))
3772 Lisp_Object a, b;
3773 { 3721 {
3774 return Flss (Fcar (a), Fcar (b)); 3722 return Flss (Fcar (a), Fcar (b));
3775 } 3723 }
3776 3724
3777 /* Heh heh heh, let's define this too, just to aggravate the person who 3725 /* Heh heh heh, let's define this too, just to aggravate the person who
3778 wrote the above comment. */ 3726 wrote the above comment. */
3779 DEFUN ("cdr-less-than-cdr", Fcdr_less_than_cdr, Scdr_less_than_cdr, 2, 2, 0 /* 3727 DEFUN ("cdr-less-than-cdr", Fcdr_less_than_cdr, 2, 2, 0, /*
3780 Return t if (cdr A) is numerically less than (cdr B). 3728 Return t if (cdr A) is numerically less than (cdr B).
3781 */ ) 3729 */
3782 (a, b) 3730 (a, b))
3783 Lisp_Object a, b;
3784 { 3731 {
3785 return Flss (Fcdr (a), Fcdr (b)); 3732 return Flss (Fcdr (a), Fcdr (b));
3786 } 3733 }
3787 3734
3788 /* Build the complete list of annotations appropriate for writing out 3735 /* Build the complete list of annotations appropriate for writing out
3920 #include <des_crypt.h> 3867 #include <des_crypt.h>
3921 3868
3922 #define CRYPT_BLOCK_SIZE 8 /* bytes */ 3869 #define CRYPT_BLOCK_SIZE 8 /* bytes */
3923 #define CRYPT_KEY_SIZE 8 /* bytes */ 3870 #define CRYPT_KEY_SIZE 8 /* bytes */
3924 3871
3925 DEFUN ("encrypt-string", Fencrypt_string, Sencrypt_string, 2, 2, 0 /* 3872 DEFUN ("encrypt-string", Fencrypt_string, 2, 2, 0, /*
3926 Encrypt STRING using KEY. 3873 Encrypt STRING using KEY.
3927 */ ) 3874 */
3928 (string, key) 3875 (string, key))
3929 Lisp_Object string, key;
3930 { 3876 {
3931 char *encrypted_string, *raw_key; 3877 char *encrypted_string, *raw_key;
3932 int rounded_size, extra, key_size; 3878 int rounded_size, extra, key_size;
3933 3879
3934 /* !!#### May produce bogus data under Mule. */ 3880 /* !!#### May produce bogus data under Mule. */
3953 (void) ecb_crypt (raw_key, encrypted_string, rounded_size, 3899 (void) ecb_crypt (raw_key, encrypted_string, rounded_size,
3954 DES_ENCRYPT | DES_SW); 3900 DES_ENCRYPT | DES_SW);
3955 return make_string (encrypted_string, rounded_size); 3901 return make_string (encrypted_string, rounded_size);
3956 } 3902 }
3957 3903
3958 DEFUN ("decrypt-string", Fdecrypt_string, Sdecrypt_string, 2, 2, 0 /* 3904 DEFUN ("decrypt-string", Fdecrypt_string, 2, 2, 0, /*
3959 Decrypt STRING using KEY. 3905 Decrypt STRING using KEY.
3960 */ ) 3906 */
3961 (string, key) 3907 (string, key))
3962 Lisp_Object string, key;
3963 { 3908 {
3964 char *decrypted_string, *raw_key; 3909 char *decrypted_string, *raw_key;
3965 int string_size, key_size; 3910 int string_size, key_size;
3966 3911
3967 CHECK_STRING (string); 3912 CHECK_STRING (string);
3987 return make_string (decrypted_string, string_size - 1); 3932 return make_string (decrypted_string, string_size - 1);
3988 } 3933 }
3989 #endif 3934 #endif
3990 3935
3991 3936
3992 DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime, 3937 DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime, 1, 1, 0, /*
3993 Sverify_visited_file_modtime, 1, 1, 0 /*
3994 Return t if last mod time of BUF's visited file matches what BUF records. 3938 Return t if last mod time of BUF's visited file matches what BUF records.
3995 This means that the file has not been changed since it was visited or saved. 3939 This means that the file has not been changed since it was visited or saved.
3996 */ ) 3940 */
3997 (buf) 3941 (buf))
3998 Lisp_Object buf;
3999 { 3942 {
4000 /* This function can GC */ 3943 /* This function can GC */
4001 struct buffer *b; 3944 struct buffer *b;
4002 struct stat st; 3945 struct stat st;
4003 Lisp_Object handler; 3946 Lisp_Object handler;
4031 || st.st_mtime == b->modtime - 1))) 3974 || st.st_mtime == b->modtime - 1)))
4032 return Qt; 3975 return Qt;
4033 return Qnil; 3976 return Qnil;
4034 } 3977 }
4035 3978
4036 DEFUN ("clear-visited-file-modtime", Fclear_visited_file_modtime, 3979 DEFUN ("clear-visited-file-modtime", Fclear_visited_file_modtime, 0, 0, 0, /*
4037 Sclear_visited_file_modtime, 0, 0, 0 /*
4038 Clear out records of last mod time of visited file. 3980 Clear out records of last mod time of visited file.
4039 Next attempt to save will certainly not complain of a discrepancy. 3981 Next attempt to save will certainly not complain of a discrepancy.
4040 */ ) 3982 */
4041 () 3983 ())
4042 { 3984 {
4043 current_buffer->modtime = 0; 3985 current_buffer->modtime = 0;
4044 return Qnil; 3986 return Qnil;
4045 } 3987 }
4046 3988
4047 DEFUN ("visited-file-modtime", Fvisited_file_modtime, 3989 DEFUN ("visited-file-modtime", Fvisited_file_modtime, 0, 0, 0, /*
4048 Svisited_file_modtime, 0, 0, 0 /*
4049 Return the current buffer's recorded visited file modification time. 3990 Return the current buffer's recorded visited file modification time.
4050 The value is a list of the form (HIGH . LOW), like the time values 3991 The value is a list of the form (HIGH . LOW), like the time values
4051 that `file-attributes' returns. 3992 that `file-attributes' returns.
4052 */ ) 3993 */
4053 () 3994 ())
4054 { 3995 {
4055 return time_to_lisp ((time_t) current_buffer->modtime); 3996 return time_to_lisp ((time_t) current_buffer->modtime);
4056 } 3997 }
4057 3998
4058 DEFUN ("set-visited-file-modtime", Fset_visited_file_modtime, 3999 DEFUN ("set-visited-file-modtime", Fset_visited_file_modtime, 0, 1, 0, /*
4059 Sset_visited_file_modtime, 0, 1, 0 /*
4060 Update buffer's recorded modification time from the visited file's time. 4000 Update buffer's recorded modification time from the visited file's time.
4061 Useful if the buffer was not read from the file normally 4001 Useful if the buffer was not read from the file normally
4062 or if the file itself has been changed for some known benign reason. 4002 or if the file itself has been changed for some known benign reason.
4063 An argument specifies the modification time value to use 4003 An argument specifies the modification time value to use
4064 (instead of that of the visited file), in the form of a list 4004 (instead of that of the visited file), in the form of a list
4065 (HIGH . LOW) or (HIGH LOW). 4005 (HIGH . LOW) or (HIGH LOW).
4066 */ ) 4006 */
4067 (time_list) 4007 (time_list))
4068 Lisp_Object time_list;
4069 { 4008 {
4070 /* This function can GC */ 4009 /* This function can GC */
4071 if (!NILP (time_list)) 4010 if (!NILP (time_list))
4072 { 4011 {
4073 time_t the_time; 4012 time_t the_time;
4097 } 4036 }
4098 4037
4099 return Qnil; 4038 return Qnil;
4100 } 4039 }
4101 4040
4102 DEFUN ("set-buffer-modtime", Fset_buffer_modtime, 4041 DEFUN ("set-buffer-modtime", Fset_buffer_modtime, 1, 2, 0, /*
4103 Sset_buffer_modtime, 1, 2, 0 /*
4104 Update BUFFER's recorded modification time from the associated 4042 Update BUFFER's recorded modification time from the associated
4105 file's modtime, if there is an associated file. If not, use the 4043 file's modtime, if there is an associated file. If not, use the
4106 current time. In either case, if the optional arg TIME is supplied, 4044 current time. In either case, if the optional arg TIME is supplied,
4107 it will be used if it is either an integer or a cons of two integers. 4045 it will be used if it is either an integer or a cons of two integers.
4108 */ ) 4046 */
4109 (buf, in_time) 4047 (buf, in_time))
4110 Lisp_Object buf, in_time;
4111 { 4048 {
4112 /* This function can GC */ 4049 /* This function can GC */
4113 unsigned long time_to_use = 0; 4050 unsigned long time_to_use = 0;
4114 int set_time_to_use = 0; 4051 int set_time_to_use = 0;
4115 struct stat st; 4052 struct stat st;
4242 The only time that Fdo_auto_save() is called while GC is in progress 4179 The only time that Fdo_auto_save() is called while GC is in progress
4243 is if we're going down, as a result of an abort() or a kill signal. 4180 is if we're going down, as a result of an abort() or a kill signal.
4244 It's fairly important that we generate autosave files in that case! 4181 It's fairly important that we generate autosave files in that case!
4245 */ 4182 */
4246 4183
4247 DEFUN ("do-auto-save", Fdo_auto_save, Sdo_auto_save, 0, 2, "" /* 4184 DEFUN ("do-auto-save", Fdo_auto_save, 0, 2, "", /*
4248 Auto-save all buffers that need it. 4185 Auto-save all buffers that need it.
4249 This is all buffers that have auto-saving enabled 4186 This is all buffers that have auto-saving enabled
4250 and are changed since last auto-saved. 4187 and are changed since last auto-saved.
4251 Auto-saving writes the buffer into a file 4188 Auto-saving writes the buffer into a file
4252 so that your editing is not lost if the system crashes. 4189 so that your editing is not lost if the system crashes.
4253 This file is not the file you visited; that changes only when you save. 4190 This file is not the file you visited; that changes only when you save.
4254 Normally we run the normal hook `auto-save-hook' before saving. 4191 Normally we run the normal hook `auto-save-hook' before saving.
4255 4192
4256 Non-nil first argument means do not print any message if successful. 4193 Non-nil first argument means do not print any message if successful.
4257 Non-nil second argument means save only current buffer. 4194 Non-nil second argument means save only current buffer.
4258 */ ) 4195 */
4259 (no_message, current_only) 4196 (no_message, current_only))
4260 Lisp_Object no_message, current_only;
4261 { 4197 {
4262 /* This function can GC */ 4198 /* This function can GC */
4263 struct buffer *old = current_buffer, *b; 4199 struct buffer *old = current_buffer, *b;
4264 Lisp_Object tail, buf; 4200 Lisp_Object tail, buf;
4265 int auto_saved = 0; 4201 int auto_saved = 0;
4463 Vquit_flag = oquit; 4399 Vquit_flag = oquit;
4464 4400
4465 RETURN_UNGCPRO (unbind_to (speccount, Qnil)); 4401 RETURN_UNGCPRO (unbind_to (speccount, Qnil));
4466 } 4402 }
4467 4403
4468 DEFUN ("set-buffer-auto-saved", Fset_buffer_auto_saved, 4404 DEFUN ("set-buffer-auto-saved", Fset_buffer_auto_saved, 0, 0, 0, /*
4469 Sset_buffer_auto_saved, 0, 0, 0 /*
4470 Mark current buffer as auto-saved with its current text. 4405 Mark current buffer as auto-saved with its current text.
4471 No auto-save file will be written until the buffer changes again. 4406 No auto-save file will be written until the buffer changes again.
4472 */ ) 4407 */
4473 () 4408 ())
4474 { 4409 {
4475 current_buffer->auto_save_modified = BUF_MODIFF (current_buffer); 4410 current_buffer->auto_save_modified = BUF_MODIFF (current_buffer);
4476 current_buffer->save_length = make_int (BUF_SIZE (current_buffer)); 4411 current_buffer->save_length = make_int (BUF_SIZE (current_buffer));
4477 current_buffer->auto_save_failure_time = -1; 4412 current_buffer->auto_save_failure_time = -1;
4478 return Qnil; 4413 return Qnil;
4479 } 4414 }
4480 4415
4481 DEFUN ("clear-buffer-auto-save-failure", Fclear_buffer_auto_save_failure, 4416 DEFUN ("clear-buffer-auto-save-failure", Fclear_buffer_auto_save_failure, 0, 0, 0, /*
4482 Sclear_buffer_auto_save_failure, 0, 0, 0 /*
4483 Clear any record of a recent auto-save failure in the current buffer. 4417 Clear any record of a recent auto-save failure in the current buffer.
4484 */ ) 4418 */
4485 () 4419 ())
4486 { 4420 {
4487 current_buffer->auto_save_failure_time = -1; 4421 current_buffer->auto_save_failure_time = -1;
4488 return Qnil; 4422 return Qnil;
4489 } 4423 }
4490 4424
4491 DEFUN ("recent-auto-save-p", Frecent_auto_save_p, Srecent_auto_save_p, 4425 DEFUN ("recent-auto-save-p", Frecent_auto_save_p, 0, 0, 0, /*
4492 0, 0, 0 /*
4493 Return t if buffer has been auto-saved since last read in or saved. 4426 Return t if buffer has been auto-saved since last read in or saved.
4494 */ ) 4427 */
4495 () 4428 ())
4496 { 4429 {
4497 return (BUF_SAVE_MODIFF (current_buffer) < 4430 return (BUF_SAVE_MODIFF (current_buffer) <
4498 current_buffer->auto_save_modified) ? Qt : Qnil; 4431 current_buffer->auto_save_modified) ? Qt : Qnil;
4499 } 4432 }
4500 4433
4553 defsymbol (&Qcompute_buffer_file_truename, "compute-buffer-file-truename"); 4486 defsymbol (&Qcompute_buffer_file_truename, "compute-buffer-file-truename");
4554 deferror (&Qfile_error, "file-error", "File error", Qio_error); 4487 deferror (&Qfile_error, "file-error", "File error", Qio_error);
4555 deferror (&Qfile_already_exists, "file-already-exists", 4488 deferror (&Qfile_already_exists, "file-already-exists",
4556 "File already exists", Qfile_error); 4489 "File already exists", Qfile_error);
4557 4490
4558 defsubr (&Sfind_file_name_handler); 4491 DEFSUBR (Ffind_file_name_handler);
4559 4492
4560 defsubr (&Sfile_name_directory); 4493 DEFSUBR (Ffile_name_directory);
4561 defsubr (&Sfile_name_nondirectory); 4494 DEFSUBR (Ffile_name_nondirectory);
4562 defsubr (&Sunhandled_file_name_directory); 4495 DEFSUBR (Funhandled_file_name_directory);
4563 defsubr (&Sfile_name_as_directory); 4496 DEFSUBR (Ffile_name_as_directory);
4564 defsubr (&Sdirectory_file_name); 4497 DEFSUBR (Fdirectory_file_name);
4565 defsubr (&Smake_temp_name); 4498 DEFSUBR (Fmake_temp_name);
4566 defsubr (&Sexpand_file_name); 4499 DEFSUBR (Fexpand_file_name);
4567 defsubr (&Sfile_truename); 4500 DEFSUBR (Ffile_truename);
4568 defsubr (&Ssubstitute_in_file_name); 4501 DEFSUBR (Fsubstitute_in_file_name);
4569 defsubr (&Scopy_file); 4502 DEFSUBR (Fcopy_file);
4570 defsubr (&Smake_directory_internal); 4503 DEFSUBR (Fmake_directory_internal);
4571 defsubr (&Sdelete_directory); 4504 DEFSUBR (Fdelete_directory);
4572 defsubr (&Sdelete_file); 4505 DEFSUBR (Fdelete_file);
4573 defsubr (&Srename_file); 4506 DEFSUBR (Frename_file);
4574 defsubr (&Sadd_name_to_file); 4507 DEFSUBR (Fadd_name_to_file);
4575 #ifdef S_IFLNK 4508 #ifdef S_IFLNK
4576 defsubr (&Smake_symbolic_link); 4509 DEFSUBR (Fmake_symbolic_link);
4577 #endif /* S_IFLNK */ 4510 #endif /* S_IFLNK */
4578 #ifdef VMS 4511 #ifdef VMS
4579 defsubr (&Sdefine_logical_name); 4512 DEFSUBR (Fdefine_logical_name);
4580 #endif /* VMS */ 4513 #endif /* VMS */
4581 #ifdef HPUX_NET 4514 #ifdef HPUX_NET
4582 defsubr (&Ssysnetunam); 4515 DEFSUBR (Fsysnetunam);
4583 #endif /* HPUX_NET */ 4516 #endif /* HPUX_NET */
4584 defsubr (&Sfile_name_absolute_p); 4517 DEFSUBR (Ffile_name_absolute_p);
4585 defsubr (&Sfile_exists_p); 4518 DEFSUBR (Ffile_exists_p);
4586 defsubr (&Sfile_executable_p); 4519 DEFSUBR (Ffile_executable_p);
4587 defsubr (&Sfile_readable_p); 4520 DEFSUBR (Ffile_readable_p);
4588 defsubr (&Sfile_writable_p); 4521 DEFSUBR (Ffile_writable_p);
4589 defsubr (&Sfile_symlink_p); 4522 DEFSUBR (Ffile_symlink_p);
4590 defsubr (&Sfile_directory_p); 4523 DEFSUBR (Ffile_directory_p);
4591 defsubr (&Sfile_accessible_directory_p); 4524 DEFSUBR (Ffile_accessible_directory_p);
4592 defsubr (&Sfile_regular_p); 4525 DEFSUBR (Ffile_regular_p);
4593 defsubr (&Sfile_modes); 4526 DEFSUBR (Ffile_modes);
4594 defsubr (&Sset_file_modes); 4527 DEFSUBR (Fset_file_modes);
4595 defsubr (&Sset_default_file_modes); 4528 DEFSUBR (Fset_default_file_modes);
4596 defsubr (&Sdefault_file_modes); 4529 DEFSUBR (Fdefault_file_modes);
4597 defsubr (&Sunix_sync); 4530 DEFSUBR (Funix_sync);
4598 defsubr (&Sfile_newer_than_file_p); 4531 DEFSUBR (Ffile_newer_than_file_p);
4599 defsubr (&Sinsert_file_contents_internal); 4532 DEFSUBR (Finsert_file_contents_internal);
4600 defsubr (&Swrite_region_internal); 4533 DEFSUBR (Fwrite_region_internal);
4601 defsubr (&Scar_less_than_car); /* Vomitous! */ 4534 DEFSUBR (Fcar_less_than_car); /* Vomitous! */
4602 defsubr (&Scdr_less_than_cdr); /* Yeah oh yeah bucko .... */ 4535 DEFSUBR (Fcdr_less_than_cdr); /* Yeah oh yeah bucko .... */
4603 #if 0 4536 #if 0
4604 defsubr (&Sencrypt_string); 4537 DEFSUBR (Fencrypt_string);
4605 defsubr (&Sdecrypt_string); 4538 DEFSUBR (Fdecrypt_string);
4606 #endif 4539 #endif
4607 defsubr (&Sverify_visited_file_modtime); 4540 DEFSUBR (Fverify_visited_file_modtime);
4608 defsubr (&Sclear_visited_file_modtime); 4541 DEFSUBR (Fclear_visited_file_modtime);
4609 defsubr (&Svisited_file_modtime); 4542 DEFSUBR (Fvisited_file_modtime);
4610 defsubr (&Sset_visited_file_modtime); 4543 DEFSUBR (Fset_visited_file_modtime);
4611 defsubr (&Sset_buffer_modtime); 4544 DEFSUBR (Fset_buffer_modtime);
4612 4545
4613 defsubr (&Sdo_auto_save); 4546 DEFSUBR (Fdo_auto_save);
4614 defsubr (&Sset_buffer_auto_saved); 4547 DEFSUBR (Fset_buffer_auto_saved);
4615 defsubr (&Sclear_buffer_auto_save_failure); 4548 DEFSUBR (Fclear_buffer_auto_save_failure);
4616 defsubr (&Srecent_auto_save_p); 4549 DEFSUBR (Frecent_auto_save_p);
4617 } 4550 }
4618 4551
4619 void 4552 void
4620 vars_of_fileio (void) 4553 vars_of_fileio (void)
4621 { 4554 {