comparison src/fileio.c @ 109179:8cfee7d2955f

Convert DEFUNs to standard C. * src/alloc.c: Convert DEFUNs to standard C. * src/buffer.c: * src/bytecode.c: * src/callint.c: * src/callproc.c: * src/casefiddle.c: * src/casetab.c: * src/category.c: * src/character.c: * src/charset.c: * src/chartab.c: * src/cmds.c: * src/coding.c: * src/composite.c: * src/data.c: * src/dbusbind.c: * src/dired.c: * src/dispnew.c: * src/doc.c: * src/dosfns.c: * src/editfns.c: * src/emacs.c: * src/eval.c: * src/fileio.c: * src/filelock.c: * src/floatfns.c: * src/fns.c: * src/font.c: * src/fontset.c: * src/frame.c: * src/fringe.c: * src/image.c: * src/indent.c: * src/insdel.c: * src/keyboard.c: * src/keymap.c: * src/lread.c: * src/macros.c: * src/marker.c: * src/menu.c: * src/minibuf.c: * src/msdos.c: * src/nsfns.m: * src/nsmenu.m: * src/nsselect.m: * src/print.c: * src/process.c: * src/search.c: * src/sound.c: * src/syntax.c: * src/term.c: * src/terminal.c: * src/textprop.c: * src/undo.c: * src/w16select.c: * src/w32console.c: * src/w32fns.c: * src/w32font.c: * src/w32menu.c: * src/w32proc.c: * src/w32select.c: * src/window.c: * src/xdisp.c: * src/xfaces.c: * src/xfns.c: * src/xmenu.c: * src/xselect.c: * src/xsettings.c: * src/xsmfns.c: Likewise.
author Dan Nicolaescu <dann@ics.uci.edu>
date Thu, 08 Jul 2010 14:25:08 -0700
parents 750db9f3e6d8
children 8f3464b85afb
comparison
equal deleted inserted replaced
109178:53f8ebcd9a97 109179:8cfee7d2955f
344 344
345 If OPERATION equals `inhibit-file-name-operation', then we ignore 345 If OPERATION equals `inhibit-file-name-operation', then we ignore
346 any handlers that are members of `inhibit-file-name-handlers', 346 any handlers that are members of `inhibit-file-name-handlers',
347 but we still do run any other handlers. This lets handlers 347 but we still do run any other handlers. This lets handlers
348 use the standard functions without calling themselves recursively. */) 348 use the standard functions without calling themselves recursively. */)
349 (filename, operation) 349 (Lisp_Object filename, Lisp_Object operation)
350 Lisp_Object filename, operation;
351 { 350 {
352 /* This function must not munge the match data. */ 351 /* This function must not munge the match data. */
353 Lisp_Object chain, inhibited_handlers, result; 352 Lisp_Object chain, inhibited_handlers, result;
354 int pos = -1; 353 int pos = -1;
355 354
401 1, 1, 0, 400 1, 1, 0,
402 doc: /* Return the directory component in file name FILENAME. 401 doc: /* Return the directory component in file name FILENAME.
403 Return nil if FILENAME does not include a directory. 402 Return nil if FILENAME does not include a directory.
404 Otherwise return a directory name. 403 Otherwise return a directory name.
405 Given a Unix syntax file name, returns a string ending in slash. */) 404 Given a Unix syntax file name, returns a string ending in slash. */)
406 (filename) 405 (Lisp_Object filename)
407 Lisp_Object filename;
408 { 406 {
409 #ifndef DOS_NT 407 #ifndef DOS_NT
410 register const unsigned char *beg; 408 register const unsigned char *beg;
411 #else 409 #else
412 register unsigned char *beg; 410 register unsigned char *beg;
476 Sfile_name_nondirectory, 1, 1, 0, 474 Sfile_name_nondirectory, 1, 1, 0,
477 doc: /* Return file name FILENAME sans its directory. 475 doc: /* Return file name FILENAME sans its directory.
478 For example, in a Unix-syntax file name, 476 For example, in a Unix-syntax file name,
479 this is everything after the last slash, 477 this is everything after the last slash,
480 or the entire name if it contains no slash. */) 478 or the entire name if it contains no slash. */)
481 (filename) 479 (Lisp_Object filename)
482 Lisp_Object filename;
483 { 480 {
484 register const unsigned char *beg, *p, *end; 481 register const unsigned char *beg, *p, *end;
485 Lisp_Object handler; 482 Lisp_Object handler;
486 483
487 CHECK_STRING (filename); 484 CHECK_STRING (filename);
517 \(file-name-directory FILENAME). 514 \(file-name-directory FILENAME).
518 If FILENAME refers to a file which is not accessible from a local process, 515 If FILENAME refers to a file which is not accessible from a local process,
519 then this should return nil. 516 then this should return nil.
520 The `call-process' and `start-process' functions use this function to 517 The `call-process' and `start-process' functions use this function to
521 get a current directory to run processes in. */) 518 get a current directory to run processes in. */)
522 (filename) 519 (Lisp_Object filename)
523 Lisp_Object filename;
524 { 520 {
525 Lisp_Object handler; 521 Lisp_Object handler;
526 522
527 /* If the file name has special constructs in it, 523 /* If the file name has special constructs in it,
528 call the corresponding file handler. */ 524 call the corresponding file handler. */
567 This operation exists because a directory is also a file, but its name as 563 This operation exists because a directory is also a file, but its name as
568 a directory is different from its name as a file. 564 a directory is different from its name as a file.
569 The result can be used as the value of `default-directory' 565 The result can be used as the value of `default-directory'
570 or passed as second argument to `expand-file-name'. 566 or passed as second argument to `expand-file-name'.
571 For a Unix-syntax file name, just appends a slash. */) 567 For a Unix-syntax file name, just appends a slash. */)
572 (file) 568 (Lisp_Object file)
573 Lisp_Object file;
574 { 569 {
575 char *buf; 570 char *buf;
576 Lisp_Object handler; 571 Lisp_Object handler;
577 572
578 CHECK_STRING (file); 573 CHECK_STRING (file);
626 doc: /* Returns the file name of the directory named DIRECTORY. 621 doc: /* Returns the file name of the directory named DIRECTORY.
627 This is the name of the file that holds the data for the directory DIRECTORY. 622 This is the name of the file that holds the data for the directory DIRECTORY.
628 This operation exists because a directory is also a file, but its name as 623 This operation exists because a directory is also a file, but its name as
629 a directory is different from its name as a file. 624 a directory is different from its name as a file.
630 In Unix-syntax, this function just removes the final slash. */) 625 In Unix-syntax, this function just removes the final slash. */)
631 (directory) 626 (Lisp_Object directory)
632 Lisp_Object directory;
633 { 627 {
634 char *buf; 628 char *buf;
635 Lisp_Object handler; 629 Lisp_Object handler;
636 630
637 CHECK_STRING (directory); 631 CHECK_STRING (directory);
799 probably use `make-temp-file' instead, except in three circumstances: 793 probably use `make-temp-file' instead, except in three circumstances:
800 794
801 * If you are creating the file in the user's home directory. 795 * If you are creating the file in the user's home directory.
802 * If you are creating a directory rather than an ordinary file. 796 * If you are creating a directory rather than an ordinary file.
803 * If you are taking special precautions as `make-temp-file' does. */) 797 * If you are taking special precautions as `make-temp-file' does. */)
804 (prefix) 798 (Lisp_Object prefix)
805 Lisp_Object prefix;
806 { 799 {
807 return make_temp_name (prefix, 0); 800 return make_temp_name (prefix, 0);
808 } 801 }
809 802
810 803
825 For technical reasons, this function can return correct but 818 For technical reasons, this function can return correct but
826 non-intuitive results for the root directory; for instance, 819 non-intuitive results for the root directory; for instance,
827 \(expand-file-name ".." "/") returns "/..". For this reason, use 820 \(expand-file-name ".." "/") returns "/..". For this reason, use
828 (directory-file-name (file-name-directory dirname)) to traverse a 821 (directory-file-name (file-name-directory dirname)) to traverse a
829 filesystem tree, not (expand-file-name ".." dirname). */) 822 filesystem tree, not (expand-file-name ".." dirname). */)
830 (name, default_directory) 823 (Lisp_Object name, Lisp_Object default_directory)
831 Lisp_Object name, default_directory;
832 { 824 {
833 /* These point to SDATA and need to be careful with string-relocation 825 /* These point to SDATA and need to be careful with string-relocation
834 during GC (via DECODE_FILE). */ 826 during GC (via DECODE_FILE). */
835 unsigned char *nm, *newdir; 827 unsigned char *nm, *newdir;
836 /* This should only point to alloca'd data. */ 828 /* This should only point to alloca'd data. */
1611 the entire variable name in braces. 1603 the entire variable name in braces.
1612 1604
1613 If `/~' appears, all of FILENAME through that `/' is discarded. 1605 If `/~' appears, all of FILENAME through that `/' is discarded.
1614 If `//' appears, everything up to and including the first of 1606 If `//' appears, everything up to and including the first of
1615 those `/' is discarded. */) 1607 those `/' is discarded. */)
1616 (filename) 1608 (Lisp_Object filename)
1617 Lisp_Object filename;
1618 { 1609 {
1619 unsigned char *nm; 1610 unsigned char *nm;
1620 1611
1621 register unsigned char *s, *p, *o, *x, *endp; 1612 register unsigned char *s, *p, *o, *x, *endp;
1622 unsigned char *target = NULL; 1613 unsigned char *target = NULL;
1903 If PRESERVE-UID-GID is non-nil, we try to transfer the 1894 If PRESERVE-UID-GID is non-nil, we try to transfer the
1904 uid and gid of FILE to NEWNAME. 1895 uid and gid of FILE to NEWNAME.
1905 1896
1906 If PRESERVE-SELINUX-CONTEXT is non-nil and SELinux is enabled 1897 If PRESERVE-SELINUX-CONTEXT is non-nil and SELinux is enabled
1907 on the system, we copy the SELinux context of FILE to NEWNAME. */) 1898 on the system, we copy the SELinux context of FILE to NEWNAME. */)
1908 (file, newname, ok_if_already_exists, keep_time, preserve_uid_gid, preserve_selinux_context) 1899 (Lisp_Object file, Lisp_Object newname, Lisp_Object ok_if_already_exists, Lisp_Object keep_time, Lisp_Object preserve_uid_gid, Lisp_Object preserve_selinux_context)
1909 Lisp_Object file, newname, ok_if_already_exists, keep_time;
1910 Lisp_Object preserve_uid_gid, preserve_selinux_context;
1911 { 1900 {
1912 int ifd, ofd, n; 1901 int ifd, ofd, n;
1913 char buf[16 * 1024]; 1902 char buf[16 * 1024];
1914 struct stat st, out_st; 1903 struct stat st, out_st;
1915 Lisp_Object handler; 1904 Lisp_Object handler;
2116 } 2105 }
2117 2106
2118 DEFUN ("make-directory-internal", Fmake_directory_internal, 2107 DEFUN ("make-directory-internal", Fmake_directory_internal,
2119 Smake_directory_internal, 1, 1, 0, 2108 Smake_directory_internal, 1, 1, 0,
2120 doc: /* Create a new directory named DIRECTORY. */) 2109 doc: /* Create a new directory named DIRECTORY. */)
2121 (directory) 2110 (Lisp_Object directory)
2122 Lisp_Object directory;
2123 { 2111 {
2124 const unsigned char *dir; 2112 const unsigned char *dir;
2125 Lisp_Object handler; 2113 Lisp_Object handler;
2126 Lisp_Object encoded_dir; 2114 Lisp_Object encoded_dir;
2127 2115
2147 } 2135 }
2148 2136
2149 DEFUN ("delete-directory-internal", Fdelete_directory_internal, 2137 DEFUN ("delete-directory-internal", Fdelete_directory_internal,
2150 Sdelete_directory_internal, 1, 1, 0, 2138 Sdelete_directory_internal, 1, 1, 0,
2151 doc: /* Delete the directory named DIRECTORY. Does not follow symlinks. */) 2139 doc: /* Delete the directory named DIRECTORY. Does not follow symlinks. */)
2152 (directory) 2140 (Lisp_Object directory)
2153 Lisp_Object directory;
2154 { 2141 {
2155 const unsigned char *dir; 2142 const unsigned char *dir;
2156 Lisp_Object handler; 2143 Lisp_Object handler;
2157 Lisp_Object encoded_dir; 2144 Lisp_Object encoded_dir;
2158 2145
2178 TRASH non-nil means to trash the file instead of deleting, provided 2165 TRASH non-nil means to trash the file instead of deleting, provided
2179 `delete-by-moving-to-trash' is non-nil. 2166 `delete-by-moving-to-trash' is non-nil.
2180 2167
2181 When called interactively, TRASH is t if no prefix argument is given. 2168 When called interactively, TRASH is t if no prefix argument is given.
2182 With a prefix argument, TRASH is nil. */) 2169 With a prefix argument, TRASH is nil. */)
2183 (filename, trash) 2170 (Lisp_Object filename, Lisp_Object trash)
2184 Lisp_Object filename;
2185 Lisp_Object trash;
2186 { 2171 {
2187 Lisp_Object handler; 2172 Lisp_Object handler;
2188 Lisp_Object encoded_file; 2173 Lisp_Object encoded_file;
2189 struct gcpro gcpro1; 2174 struct gcpro gcpro1;
2190 2175
2236 If file has names other than FILE, it continues to have those names. 2221 If file has names other than FILE, it continues to have those names.
2237 Signals a `file-already-exists' error if a file NEWNAME already exists 2222 Signals a `file-already-exists' error if a file NEWNAME already exists
2238 unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. 2223 unless optional third argument OK-IF-ALREADY-EXISTS is non-nil.
2239 A number as third arg means request confirmation if NEWNAME already exists. 2224 A number as third arg means request confirmation if NEWNAME already exists.
2240 This is what happens in interactive use with M-x. */) 2225 This is what happens in interactive use with M-x. */)
2241 (file, newname, ok_if_already_exists) 2226 (Lisp_Object file, Lisp_Object newname, Lisp_Object ok_if_already_exists)
2242 Lisp_Object file, newname, ok_if_already_exists;
2243 { 2227 {
2244 Lisp_Object handler; 2228 Lisp_Object handler;
2245 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 2229 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
2246 Lisp_Object encoded_file, encoded_newname, symlink_target; 2230 Lisp_Object encoded_file, encoded_newname, symlink_target;
2247 2231
2334 doc: /* Give FILE additional name NEWNAME. Both args must be strings. 2318 doc: /* Give FILE additional name NEWNAME. Both args must be strings.
2335 Signals a `file-already-exists' error if a file NEWNAME already exists 2319 Signals a `file-already-exists' error if a file NEWNAME already exists
2336 unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. 2320 unless optional third argument OK-IF-ALREADY-EXISTS is non-nil.
2337 A number as third arg means request confirmation if NEWNAME already exists. 2321 A number as third arg means request confirmation if NEWNAME already exists.
2338 This is what happens in interactive use with M-x. */) 2322 This is what happens in interactive use with M-x. */)
2339 (file, newname, ok_if_already_exists) 2323 (Lisp_Object file, Lisp_Object newname, Lisp_Object ok_if_already_exists)
2340 Lisp_Object file, newname, ok_if_already_exists;
2341 { 2324 {
2342 Lisp_Object handler; 2325 Lisp_Object handler;
2343 Lisp_Object encoded_file, encoded_newname; 2326 Lisp_Object encoded_file, encoded_newname;
2344 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 2327 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
2345 2328
2390 Both args must be strings. 2373 Both args must be strings.
2391 Signals a `file-already-exists' error if a file LINKNAME already exists 2374 Signals a `file-already-exists' error if a file LINKNAME already exists
2392 unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. 2375 unless optional third argument OK-IF-ALREADY-EXISTS is non-nil.
2393 A number as third arg means request confirmation if LINKNAME already exists. 2376 A number as third arg means request confirmation if LINKNAME already exists.
2394 This happens for interactive use with M-x. */) 2377 This happens for interactive use with M-x. */)
2395 (filename, linkname, ok_if_already_exists) 2378 (Lisp_Object filename, Lisp_Object linkname, Lisp_Object ok_if_already_exists)
2396 Lisp_Object filename, linkname, ok_if_already_exists;
2397 { 2379 {
2398 Lisp_Object handler; 2380 Lisp_Object handler;
2399 Lisp_Object encoded_filename, encoded_linkname; 2381 Lisp_Object encoded_filename, encoded_linkname;
2400 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 2382 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
2401 2383
2466 2448
2467 DEFUN ("file-name-absolute-p", Ffile_name_absolute_p, Sfile_name_absolute_p, 2449 DEFUN ("file-name-absolute-p", Ffile_name_absolute_p, Sfile_name_absolute_p,
2468 1, 1, 0, 2450 1, 1, 0,
2469 doc: /* Return t if file FILENAME specifies an absolute file name. 2451 doc: /* Return t if file FILENAME specifies an absolute file name.
2470 On Unix, this is a name starting with a `/' or a `~'. */) 2452 On Unix, this is a name starting with a `/' or a `~'. */)
2471 (filename) 2453 (Lisp_Object filename)
2472 Lisp_Object filename;
2473 { 2454 {
2474 CHECK_STRING (filename); 2455 CHECK_STRING (filename);
2475 return file_name_absolute_p (SDATA (filename)) ? Qt : Qnil; 2456 return file_name_absolute_p (SDATA (filename)) ? Qt : Qnil;
2476 } 2457 }
2477 2458
2526 DEFUN ("file-exists-p", Ffile_exists_p, Sfile_exists_p, 1, 1, 0, 2507 DEFUN ("file-exists-p", Ffile_exists_p, Sfile_exists_p, 1, 1, 0,
2527 doc: /* Return t if file FILENAME exists (whether or not you can read it.) 2508 doc: /* Return t if file FILENAME exists (whether or not you can read it.)
2528 See also `file-readable-p' and `file-attributes'. 2509 See also `file-readable-p' and `file-attributes'.
2529 This returns nil for a symlink to a nonexistent file. 2510 This returns nil for a symlink to a nonexistent file.
2530 Use `file-symlink-p' to test for such links. */) 2511 Use `file-symlink-p' to test for such links. */)
2531 (filename) 2512 (Lisp_Object filename)
2532 Lisp_Object filename;
2533 { 2513 {
2534 Lisp_Object absname; 2514 Lisp_Object absname;
2535 Lisp_Object handler; 2515 Lisp_Object handler;
2536 struct stat statbuf; 2516 struct stat statbuf;
2537 2517
2550 } 2530 }
2551 2531
2552 DEFUN ("file-executable-p", Ffile_executable_p, Sfile_executable_p, 1, 1, 0, 2532 DEFUN ("file-executable-p", Ffile_executable_p, Sfile_executable_p, 1, 1, 0,
2553 doc: /* Return t if FILENAME can be executed by you. 2533 doc: /* Return t if FILENAME can be executed by you.
2554 For a directory, this means you can access files in that directory. */) 2534 For a directory, this means you can access files in that directory. */)
2555 (filename) 2535 (Lisp_Object filename)
2556 Lisp_Object filename;
2557 { 2536 {
2558 Lisp_Object absname; 2537 Lisp_Object absname;
2559 Lisp_Object handler; 2538 Lisp_Object handler;
2560 2539
2561 CHECK_STRING (filename); 2540 CHECK_STRING (filename);
2573 } 2552 }
2574 2553
2575 DEFUN ("file-readable-p", Ffile_readable_p, Sfile_readable_p, 1, 1, 0, 2554 DEFUN ("file-readable-p", Ffile_readable_p, Sfile_readable_p, 1, 1, 0,
2576 doc: /* Return t if file FILENAME exists and you can read it. 2555 doc: /* Return t if file FILENAME exists and you can read it.
2577 See also `file-exists-p' and `file-attributes'. */) 2556 See also `file-exists-p' and `file-attributes'. */)
2578 (filename) 2557 (Lisp_Object filename)
2579 Lisp_Object filename;
2580 { 2558 {
2581 Lisp_Object absname; 2559 Lisp_Object absname;
2582 Lisp_Object handler; 2560 Lisp_Object handler;
2583 int desc; 2561 int desc;
2584 int flags; 2562 int flags;
2623 2601
2624 /* Having this before file-symlink-p mysteriously caused it to be forgotten 2602 /* Having this before file-symlink-p mysteriously caused it to be forgotten
2625 on the RT/PC. */ 2603 on the RT/PC. */
2626 DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0, 2604 DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0,
2627 doc: /* Return t if file FILENAME can be written or created by you. */) 2605 doc: /* Return t if file FILENAME can be written or created by you. */)
2628 (filename) 2606 (Lisp_Object filename)
2629 Lisp_Object filename;
2630 { 2607 {
2631 Lisp_Object absname, dir, encoded; 2608 Lisp_Object absname, dir, encoded;
2632 Lisp_Object handler; 2609 Lisp_Object handler;
2633 struct stat statbuf; 2610 struct stat statbuf;
2634 2611
2668 2645
2669 DEFUN ("access-file", Faccess_file, Saccess_file, 2, 2, 0, 2646 DEFUN ("access-file", Faccess_file, Saccess_file, 2, 2, 0,
2670 doc: /* Access file FILENAME, and get an error if that does not work. 2647 doc: /* Access file FILENAME, and get an error if that does not work.
2671 The second argument STRING is used in the error message. 2648 The second argument STRING is used in the error message.
2672 If there is no error, returns nil. */) 2649 If there is no error, returns nil. */)
2673 (filename, string) 2650 (Lisp_Object filename, Lisp_Object string)
2674 Lisp_Object filename, string;
2675 { 2651 {
2676 Lisp_Object handler, encoded_filename, absname; 2652 Lisp_Object handler, encoded_filename, absname;
2677 int fd; 2653 int fd;
2678 2654
2679 CHECK_STRING (filename); 2655 CHECK_STRING (filename);
2702 The value is the link target, as a string. 2678 The value is the link target, as a string.
2703 Otherwise it returns nil. 2679 Otherwise it returns nil.
2704 2680
2705 This function returns t when given the name of a symlink that 2681 This function returns t when given the name of a symlink that
2706 points to a nonexistent file. */) 2682 points to a nonexistent file. */)
2707 (filename) 2683 (Lisp_Object filename)
2708 Lisp_Object filename;
2709 { 2684 {
2710 Lisp_Object handler; 2685 Lisp_Object handler;
2711 2686
2712 CHECK_STRING (filename); 2687 CHECK_STRING (filename);
2713 filename = Fexpand_file_name (filename, Qnil); 2688 filename = Fexpand_file_name (filename, Qnil);
2767 2742
2768 DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0, 2743 DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0,
2769 doc: /* Return t if FILENAME names an existing directory. 2744 doc: /* Return t if FILENAME names an existing directory.
2770 Symbolic links to directories count as directories. 2745 Symbolic links to directories count as directories.
2771 See `file-symlink-p' to distinguish symlinks. */) 2746 See `file-symlink-p' to distinguish symlinks. */)
2772 (filename) 2747 (Lisp_Object filename)
2773 Lisp_Object filename;
2774 { 2748 {
2775 register Lisp_Object absname; 2749 register Lisp_Object absname;
2776 struct stat st; 2750 struct stat st;
2777 Lisp_Object handler; 2751 Lisp_Object handler;
2778 2752
2797 and the directory must allow you to open files in it. In order to use a 2771 and the directory must allow you to open files in it. In order to use a
2798 directory as a buffer's current directory, this predicate must return true. 2772 directory as a buffer's current directory, this predicate must return true.
2799 A directory name spec may be given instead; then the value is t 2773 A directory name spec may be given instead; then the value is t
2800 if the directory so specified exists and really is a readable and 2774 if the directory so specified exists and really is a readable and
2801 searchable directory. */) 2775 searchable directory. */)
2802 (filename) 2776 (Lisp_Object filename)
2803 Lisp_Object filename;
2804 { 2777 {
2805 Lisp_Object handler; 2778 Lisp_Object handler;
2806 int tem; 2779 int tem;
2807 struct gcpro gcpro1; 2780 struct gcpro gcpro1;
2808 2781
2822 DEFUN ("file-regular-p", Ffile_regular_p, Sfile_regular_p, 1, 1, 0, 2795 DEFUN ("file-regular-p", Ffile_regular_p, Sfile_regular_p, 1, 1, 0,
2823 doc: /* Return t if FILENAME names a regular file. 2796 doc: /* Return t if FILENAME names a regular file.
2824 This is the sort of file that holds an ordinary stream of data bytes. 2797 This is the sort of file that holds an ordinary stream of data bytes.
2825 Symbolic links to regular files count as regular files. 2798 Symbolic links to regular files count as regular files.
2826 See `file-symlink-p' to distinguish symlinks. */) 2799 See `file-symlink-p' to distinguish symlinks. */)
2827 (filename) 2800 (Lisp_Object filename)
2828 Lisp_Object filename;
2829 { 2801 {
2830 register Lisp_Object absname; 2802 register Lisp_Object absname;
2831 struct stat st; 2803 struct stat st;
2832 Lisp_Object handler; 2804 Lisp_Object handler;
2833 2805
2865 DEFUN ("file-selinux-context", Ffile_selinux_context, 2837 DEFUN ("file-selinux-context", Ffile_selinux_context,
2866 Sfile_selinux_context, 1, 1, 0, 2838 Sfile_selinux_context, 1, 1, 0,
2867 doc: /* Return SELinux context of file named FILENAME, 2839 doc: /* Return SELinux context of file named FILENAME,
2868 as a list ("user", "role", "type", "range"). Return (nil, nil, nil, nil) 2840 as a list ("user", "role", "type", "range"). Return (nil, nil, nil, nil)
2869 if file does not exist, is not accessible, or SELinux is disabled */) 2841 if file does not exist, is not accessible, or SELinux is disabled */)
2870 (filename) 2842 (Lisp_Object filename)
2871 Lisp_Object filename;
2872 { 2843 {
2873 Lisp_Object absname; 2844 Lisp_Object absname;
2874 Lisp_Object values[4]; 2845 Lisp_Object values[4];
2875 Lisp_Object handler; 2846 Lisp_Object handler;
2876 #if HAVE_LIBSELINUX 2847 #if HAVE_LIBSELINUX
2921 DEFUN ("set-file-selinux-context", Fset_file_selinux_context, 2892 DEFUN ("set-file-selinux-context", Fset_file_selinux_context,
2922 Sset_file_selinux_context, 2, 2, 0, 2893 Sset_file_selinux_context, 2, 2, 0,
2923 doc: /* Set SELinux context of file named FILENAME to CONTEXT 2894 doc: /* Set SELinux context of file named FILENAME to CONTEXT
2924 as a list ("user", "role", "type", "range"). Has no effect if SELinux 2895 as a list ("user", "role", "type", "range"). Has no effect if SELinux
2925 is disabled. */) 2896 is disabled. */)
2926 (filename, context) 2897 (Lisp_Object filename, Lisp_Object context)
2927 Lisp_Object filename, context;
2928 { 2898 {
2929 Lisp_Object absname, encoded_absname; 2899 Lisp_Object absname, encoded_absname;
2930 Lisp_Object handler; 2900 Lisp_Object handler;
2931 Lisp_Object user = CAR_SAFE (context); 2901 Lisp_Object user = CAR_SAFE (context);
2932 Lisp_Object role = CAR_SAFE (CDR_SAFE (context)); 2902 Lisp_Object role = CAR_SAFE (CDR_SAFE (context));
2997 } 2967 }
2998 2968
2999 DEFUN ("file-modes", Ffile_modes, Sfile_modes, 1, 1, 0, 2969 DEFUN ("file-modes", Ffile_modes, Sfile_modes, 1, 1, 0,
3000 doc: /* Return mode bits of file named FILENAME, as an integer. 2970 doc: /* Return mode bits of file named FILENAME, as an integer.
3001 Return nil, if file does not exist or is not accessible. */) 2971 Return nil, if file does not exist or is not accessible. */)
3002 (filename) 2972 (Lisp_Object filename)
3003 Lisp_Object filename;
3004 { 2973 {
3005 Lisp_Object absname; 2974 Lisp_Object absname;
3006 struct stat st; 2975 struct stat st;
3007 Lisp_Object handler; 2976 Lisp_Object handler;
3008 2977
3028 doc: /* Set mode bits of file named FILENAME to MODE (an integer). 2997 doc: /* Set mode bits of file named FILENAME to MODE (an integer).
3029 Only the 12 low bits of MODE are used. 2998 Only the 12 low bits of MODE are used.
3030 2999
3031 Interactively, mode bits are read by `read-file-modes', which accepts 3000 Interactively, mode bits are read by `read-file-modes', which accepts
3032 symbolic notation, like the `chmod' command from GNU Coreutils. */) 3001 symbolic notation, like the `chmod' command from GNU Coreutils. */)
3033 (filename, mode) 3002 (Lisp_Object filename, Lisp_Object mode)
3034 Lisp_Object filename, mode;
3035 { 3003 {
3036 Lisp_Object absname, encoded_absname; 3004 Lisp_Object absname, encoded_absname;
3037 Lisp_Object handler; 3005 Lisp_Object handler;
3038 3006
3039 absname = Fexpand_file_name (filename, current_buffer->directory); 3007 absname = Fexpand_file_name (filename, current_buffer->directory);
3055 3023
3056 DEFUN ("set-default-file-modes", Fset_default_file_modes, Sset_default_file_modes, 1, 1, 0, 3024 DEFUN ("set-default-file-modes", Fset_default_file_modes, Sset_default_file_modes, 1, 1, 0,
3057 doc: /* Set the file permission bits for newly created files. 3025 doc: /* Set the file permission bits for newly created files.
3058 The argument MODE should be an integer; only the low 9 bits are used. 3026 The argument MODE should be an integer; only the low 9 bits are used.
3059 This setting is inherited by subprocesses. */) 3027 This setting is inherited by subprocesses. */)
3060 (mode) 3028 (Lisp_Object mode)
3061 Lisp_Object mode;
3062 { 3029 {
3063 CHECK_NUMBER (mode); 3030 CHECK_NUMBER (mode);
3064 3031
3065 umask ((~ XINT (mode)) & 0777); 3032 umask ((~ XINT (mode)) & 0777);
3066 3033
3068 } 3035 }
3069 3036
3070 DEFUN ("default-file-modes", Fdefault_file_modes, Sdefault_file_modes, 0, 0, 0, 3037 DEFUN ("default-file-modes", Fdefault_file_modes, Sdefault_file_modes, 0, 0, 0,
3071 doc: /* Return the default file protection for created files. 3038 doc: /* Return the default file protection for created files.
3072 The value is an integer. */) 3039 The value is an integer. */)
3073 () 3040 (void)
3074 { 3041 {
3075 int realmask; 3042 int realmask;
3076 Lisp_Object value; 3043 Lisp_Object value;
3077 3044
3078 realmask = umask (0); 3045 realmask = umask (0);
3088 doc: /* Set times of file FILENAME to TIME. 3055 doc: /* Set times of file FILENAME to TIME.
3089 Set both access and modification times. 3056 Set both access and modification times.
3090 Return t on success, else nil. 3057 Return t on success, else nil.
3091 Use the current time if TIME is nil. TIME is in the format of 3058 Use the current time if TIME is nil. TIME is in the format of
3092 `current-time'. */) 3059 `current-time'. */)
3093 (filename, time) 3060 (Lisp_Object filename, Lisp_Object time)
3094 Lisp_Object filename, time;
3095 { 3061 {
3096 Lisp_Object absname, encoded_absname; 3062 Lisp_Object absname, encoded_absname;
3097 Lisp_Object handler; 3063 Lisp_Object handler;
3098 time_t sec; 3064 time_t sec;
3099 int usec; 3065 int usec;
3136 } 3102 }
3137 3103
3138 #ifdef HAVE_SYNC 3104 #ifdef HAVE_SYNC
3139 DEFUN ("unix-sync", Funix_sync, Sunix_sync, 0, 0, "", 3105 DEFUN ("unix-sync", Funix_sync, Sunix_sync, 0, 0, "",
3140 doc: /* Tell Unix to finish all pending disk updates. */) 3106 doc: /* Tell Unix to finish all pending disk updates. */)
3141 () 3107 (void)
3142 { 3108 {
3143 sync (); 3109 sync ();
3144 return Qnil; 3110 return Qnil;
3145 } 3111 }
3146 3112
3148 3114
3149 DEFUN ("file-newer-than-file-p", Ffile_newer_than_file_p, Sfile_newer_than_file_p, 2, 2, 0, 3115 DEFUN ("file-newer-than-file-p", Ffile_newer_than_file_p, Sfile_newer_than_file_p, 2, 2, 0,
3150 doc: /* Return t if file FILE1 is newer than file FILE2. 3116 doc: /* Return t if file FILE1 is newer than file FILE2.
3151 If FILE1 does not exist, the answer is nil; 3117 If FILE1 does not exist, the answer is nil;
3152 otherwise, if FILE2 does not exist, the answer is t. */) 3118 otherwise, if FILE2 does not exist, the answer is t. */)
3153 (file1, file2) 3119 (Lisp_Object file1, Lisp_Object file2)
3154 Lisp_Object file1, file2;
3155 { 3120 {
3156 Lisp_Object absname1, absname2; 3121 Lisp_Object absname1, absname2;
3157 struct stat st; 3122 struct stat st;
3158 int mtime1; 3123 int mtime1;
3159 Lisp_Object handler; 3124 Lisp_Object handler;
3298 the number of characters that replace previous buffer contents. 3263 the number of characters that replace previous buffer contents.
3299 3264
3300 This function does code conversion according to the value of 3265 This function does code conversion according to the value of
3301 `coding-system-for-read' or `file-coding-system-alist', and sets the 3266 `coding-system-for-read' or `file-coding-system-alist', and sets the
3302 variable `last-coding-system-used' to the coding system actually used. */) 3267 variable `last-coding-system-used' to the coding system actually used. */)
3303 (filename, visit, beg, end, replace) 3268 (Lisp_Object filename, Lisp_Object visit, Lisp_Object beg, Lisp_Object end, Lisp_Object replace)
3304 Lisp_Object filename, visit, beg, end, replace;
3305 { 3269 {
3306 struct stat st; 3270 struct stat st;
3307 register int fd; 3271 register int fd;
3308 EMACS_INT inserted = 0; 3272 EMACS_INT inserted = 0;
3309 int nochange = 0; 3273 int nochange = 0;
4578 `file-coding-system-alist', and sets the variable 4542 `file-coding-system-alist', and sets the variable
4579 `last-coding-system-used' to the coding system actually used. 4543 `last-coding-system-used' to the coding system actually used.
4580 4544
4581 This calls `write-region-annotate-functions' at the start, and 4545 This calls `write-region-annotate-functions' at the start, and
4582 `write-region-post-annotation-function' at the end. */) 4546 `write-region-post-annotation-function' at the end. */)
4583 (start, end, filename, append, visit, lockname, mustbenew) 4547 (Lisp_Object start, Lisp_Object end, Lisp_Object filename, Lisp_Object append, Lisp_Object visit, Lisp_Object lockname, Lisp_Object mustbenew)
4584 Lisp_Object start, end, filename, append, visit, lockname, mustbenew;
4585 { 4548 {
4586 register int desc; 4549 register int desc;
4587 int failure; 4550 int failure;
4588 int save_errno = 0; 4551 int save_errno = 0;
4589 const unsigned char *fn; 4552 const unsigned char *fn;
4884 4847
4885 Lisp_Object merge (Lisp_Object, Lisp_Object, Lisp_Object); 4848 Lisp_Object merge (Lisp_Object, Lisp_Object, Lisp_Object);
4886 4849
4887 DEFUN ("car-less-than-car", Fcar_less_than_car, Scar_less_than_car, 2, 2, 0, 4850 DEFUN ("car-less-than-car", Fcar_less_than_car, Scar_less_than_car, 2, 2, 0,
4888 doc: /* Return t if (car A) is numerically less than (car B). */) 4851 doc: /* Return t if (car A) is numerically less than (car B). */)
4889 (a, b) 4852 (Lisp_Object a, Lisp_Object b)
4890 Lisp_Object a, b;
4891 { 4853 {
4892 return Flss (Fcar (a), Fcar (b)); 4854 return Flss (Fcar (a), Fcar (b));
4893 } 4855 }
4894 4856
4895 /* Build the complete list of annotations appropriate for writing out 4857 /* Build the complete list of annotations appropriate for writing out
5112 DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime, 5074 DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime,
5113 Sverify_visited_file_modtime, 1, 1, 0, 5075 Sverify_visited_file_modtime, 1, 1, 0,
5114 doc: /* Return t if last mod time of BUF's visited file matches what BUF records. 5076 doc: /* Return t if last mod time of BUF's visited file matches what BUF records.
5115 This means that the file has not been changed since it was visited or saved. 5077 This means that the file has not been changed since it was visited or saved.
5116 See Info node `(elisp)Modification Time' for more details. */) 5078 See Info node `(elisp)Modification Time' for more details. */)
5117 (buf) 5079 (Lisp_Object buf)
5118 Lisp_Object buf;
5119 { 5080 {
5120 struct buffer *b; 5081 struct buffer *b;
5121 struct stat st; 5082 struct stat st;
5122 Lisp_Object handler; 5083 Lisp_Object handler;
5123 Lisp_Object filename; 5084 Lisp_Object filename;
5159 5120
5160 DEFUN ("clear-visited-file-modtime", Fclear_visited_file_modtime, 5121 DEFUN ("clear-visited-file-modtime", Fclear_visited_file_modtime,
5161 Sclear_visited_file_modtime, 0, 0, 0, 5122 Sclear_visited_file_modtime, 0, 0, 0,
5162 doc: /* Clear out records of last mod time of visited file. 5123 doc: /* Clear out records of last mod time of visited file.
5163 Next attempt to save will certainly not complain of a discrepancy. */) 5124 Next attempt to save will certainly not complain of a discrepancy. */)
5164 () 5125 (void)
5165 { 5126 {
5166 current_buffer->modtime = 0; 5127 current_buffer->modtime = 0;
5167 current_buffer->modtime_size = -1; 5128 current_buffer->modtime_size = -1;
5168 return Qnil; 5129 return Qnil;
5169 } 5130 }
5173 doc: /* Return the current buffer's recorded visited file modification time. 5134 doc: /* Return the current buffer's recorded visited file modification time.
5174 The value is a list of the form (HIGH LOW), like the time values 5135 The value is a list of the form (HIGH LOW), like the time values
5175 that `file-attributes' returns. If the current buffer has no recorded 5136 that `file-attributes' returns. If the current buffer has no recorded
5176 file modification time, this function returns 0. 5137 file modification time, this function returns 0.
5177 See Info node `(elisp)Modification Time' for more details. */) 5138 See Info node `(elisp)Modification Time' for more details. */)
5178 () 5139 (void)
5179 { 5140 {
5180 if (! current_buffer->modtime) 5141 if (! current_buffer->modtime)
5181 return make_number (0); 5142 return make_number (0);
5182 return make_time ((time_t) current_buffer->modtime); 5143 return make_time ((time_t) current_buffer->modtime);
5183 } 5144 }
5188 Useful if the buffer was not read from the file normally 5149 Useful if the buffer was not read from the file normally
5189 or if the file itself has been changed for some known benign reason. 5150 or if the file itself has been changed for some known benign reason.
5190 An argument specifies the modification time value to use 5151 An argument specifies the modification time value to use
5191 \(instead of that of the visited file), in the form of a list 5152 \(instead of that of the visited file), in the form of a list
5192 \(HIGH . LOW) or (HIGH LOW). */) 5153 \(HIGH . LOW) or (HIGH LOW). */)
5193 (time_list) 5154 (Lisp_Object time_list)
5194 Lisp_Object time_list;
5195 { 5155 {
5196 if (!NILP (time_list)) 5156 if (!NILP (time_list))
5197 { 5157 {
5198 current_buffer->modtime = cons_to_long (time_list); 5158 current_buffer->modtime = cons_to_long (time_list);
5199 current_buffer->modtime_size = -1; 5159 current_buffer->modtime_size = -1;
5335 This file is not the file you visited; that changes only when you save. 5295 This file is not the file you visited; that changes only when you save.
5336 Normally we run the normal hook `auto-save-hook' before saving. 5296 Normally we run the normal hook `auto-save-hook' before saving.
5337 5297
5338 A non-nil NO-MESSAGE argument means do not print any message if successful. 5298 A non-nil NO-MESSAGE argument means do not print any message if successful.
5339 A non-nil CURRENT-ONLY argument means save only current buffer. */) 5299 A non-nil CURRENT-ONLY argument means save only current buffer. */)
5340 (no_message, current_only) 5300 (Lisp_Object no_message, Lisp_Object current_only)
5341 Lisp_Object no_message, current_only;
5342 { 5301 {
5343 struct buffer *old = current_buffer, *b; 5302 struct buffer *old = current_buffer, *b;
5344 Lisp_Object tail, buf; 5303 Lisp_Object tail, buf;
5345 int auto_saved = 0; 5304 int auto_saved = 0;
5346 int do_handled_files; 5305 int do_handled_files;
5537 5496
5538 DEFUN ("set-buffer-auto-saved", Fset_buffer_auto_saved, 5497 DEFUN ("set-buffer-auto-saved", Fset_buffer_auto_saved,
5539 Sset_buffer_auto_saved, 0, 0, 0, 5498 Sset_buffer_auto_saved, 0, 0, 0,
5540 doc: /* Mark current buffer as auto-saved with its current text. 5499 doc: /* Mark current buffer as auto-saved with its current text.
5541 No auto-save file will be written until the buffer changes again. */) 5500 No auto-save file will be written until the buffer changes again. */)
5542 () 5501 (void)
5543 { 5502 {
5544 /* FIXME: This should not be called in indirect buffers, since 5503 /* FIXME: This should not be called in indirect buffers, since
5545 they're not autosaved. */ 5504 they're not autosaved. */
5546 BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF; 5505 BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF;
5547 XSETFASTINT (current_buffer->save_length, Z - BEG); 5506 XSETFASTINT (current_buffer->save_length, Z - BEG);
5550 } 5509 }
5551 5510
5552 DEFUN ("clear-buffer-auto-save-failure", Fclear_buffer_auto_save_failure, 5511 DEFUN ("clear-buffer-auto-save-failure", Fclear_buffer_auto_save_failure,
5553 Sclear_buffer_auto_save_failure, 0, 0, 0, 5512 Sclear_buffer_auto_save_failure, 0, 0, 0,
5554 doc: /* Clear any record of a recent auto-save failure in the current buffer. */) 5513 doc: /* Clear any record of a recent auto-save failure in the current buffer. */)
5555 () 5514 (void)
5556 { 5515 {
5557 current_buffer->auto_save_failure_time = -1; 5516 current_buffer->auto_save_failure_time = -1;
5558 return Qnil; 5517 return Qnil;
5559 } 5518 }
5560 5519
5562 0, 0, 0, 5521 0, 0, 0,
5563 doc: /* Return t if current buffer has been auto-saved recently. 5522 doc: /* Return t if current buffer has been auto-saved recently.
5564 More precisely, if it has been auto-saved since last read from or saved 5523 More precisely, if it has been auto-saved since last read from or saved
5565 in the visited file. If the buffer has no visited file, 5524 in the visited file. If the buffer has no visited file,
5566 then any auto-save counts as "recent". */) 5525 then any auto-save counts as "recent". */)
5567 () 5526 (void)
5568 { 5527 {
5569 /* FIXME: maybe we should return nil for indirect buffers since 5528 /* FIXME: maybe we should return nil for indirect buffers since
5570 they're never autosaved. */ 5529 they're never autosaved. */
5571 return (SAVE_MODIFF < BUF_AUTOSAVE_MODIFF (current_buffer) ? Qt : Qnil); 5530 return (SAVE_MODIFF < BUF_AUTOSAVE_MODIFF (current_buffer) ? Qt : Qnil);
5572 } 5531 }
5576 DEFUN ("next-read-file-uses-dialog-p", Fnext_read_file_uses_dialog_p, 5535 DEFUN ("next-read-file-uses-dialog-p", Fnext_read_file_uses_dialog_p,
5577 Snext_read_file_uses_dialog_p, 0, 0, 0, 5536 Snext_read_file_uses_dialog_p, 0, 0, 0,
5578 doc: /* Return t if a call to `read-file-name' will use a dialog. 5537 doc: /* Return t if a call to `read-file-name' will use a dialog.
5579 The return value is only relevant for a call to `read-file-name' that happens 5538 The return value is only relevant for a call to `read-file-name' that happens
5580 before any other event (mouse or keypress) is handled. */) 5539 before any other event (mouse or keypress) is handled. */)
5581 () 5540 (void)
5582 { 5541 {
5583 #if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) 5542 #if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK)
5584 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) 5543 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
5585 && use_dialog_box 5544 && use_dialog_box
5586 && use_file_dialog 5545 && use_file_dialog