Mercurial > emacs
comparison src/fileio.c @ 16155:ddc7e0142964
(Faccess_file): New function.
(Qaccess_file): New variable.
(syms_of_fileio): defsubr function; init and staticpro Qaccess_file.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 10 Sep 1996 19:54:02 +0000 |
parents | 63b85944e37b |
children | 651ee074f8b0 |
comparison
equal
deleted
inserted
replaced
16154:a9160d6d9ac7 | 16155:ddc7e0142964 |
---|---|
247 Lisp_Object Qadd_name_to_file; | 247 Lisp_Object Qadd_name_to_file; |
248 Lisp_Object Qmake_symbolic_link; | 248 Lisp_Object Qmake_symbolic_link; |
249 Lisp_Object Qfile_exists_p; | 249 Lisp_Object Qfile_exists_p; |
250 Lisp_Object Qfile_executable_p; | 250 Lisp_Object Qfile_executable_p; |
251 Lisp_Object Qfile_readable_p; | 251 Lisp_Object Qfile_readable_p; |
252 Lisp_Object Qfile_writable_p; | |
252 Lisp_Object Qfile_symlink_p; | 253 Lisp_Object Qfile_symlink_p; |
253 Lisp_Object Qfile_writable_p; | 254 Lisp_Object Qaccess_file; |
254 Lisp_Object Qfile_directory_p; | 255 Lisp_Object Qfile_directory_p; |
255 Lisp_Object Qfile_regular_p; | 256 Lisp_Object Qfile_regular_p; |
256 Lisp_Object Qfile_accessible_directory_p; | 257 Lisp_Object Qfile_accessible_directory_p; |
257 Lisp_Object Qfile_modes; | 258 Lisp_Object Qfile_modes; |
258 Lisp_Object Qset_file_modes; | 259 Lisp_Object Qset_file_modes; |
2692 #endif /* MSDOS */ | 2693 #endif /* MSDOS */ |
2693 return (check_writable (!NILP (dir) ? (char *) XSTRING (dir)->data : "") | 2694 return (check_writable (!NILP (dir) ? (char *) XSTRING (dir)->data : "") |
2694 ? Qt : Qnil); | 2695 ? Qt : Qnil); |
2695 } | 2696 } |
2696 | 2697 |
2698 DEFUN ("access-file", Faccess_file, Saccess_file, 2, 2, 0, | |
2699 "Access file FILENAME, and get an error if that does not work.\n\ | |
2700 The second argument STRING is used in the error message.\n\ | |
2701 If there is no error, we return nil.") | |
2702 (filename, string) | |
2703 Lisp_Object filename, string; | |
2704 { | |
2705 Lisp_Object handler; | |
2706 int fd; | |
2707 | |
2708 CHECK_STRING (filename, 0); | |
2709 | |
2710 /* If the file name has special constructs in it, | |
2711 call the corresponding file handler. */ | |
2712 handler = Ffind_file_name_handler (filename, Qaccess_file); | |
2713 if (!NILP (handler)) | |
2714 return call3 (handler, Qaccess_file, filename, string); | |
2715 | |
2716 fd = open (XSTRING (filename)->data, O_RDONLY); | |
2717 if (fd < 0) | |
2718 report_file_error (XSTRING (string)->data, Fcons (filename, Qnil)); | |
2719 close (fd); | |
2720 | |
2721 return Qnil; | |
2722 } | |
2723 | |
2697 DEFUN ("file-symlink-p", Ffile_symlink_p, Sfile_symlink_p, 1, 1, 0, | 2724 DEFUN ("file-symlink-p", Ffile_symlink_p, Sfile_symlink_p, 1, 1, 0, |
2698 "Return non-nil if file FILENAME is the name of a symbolic link.\n\ | 2725 "Return non-nil if file FILENAME is the name of a symbolic link.\n\ |
2699 The value is the name of the file to which it is linked.\n\ | 2726 The value is the name of the file to which it is linked.\n\ |
2700 Otherwise returns nil.") | 2727 Otherwise returns nil.") |
2701 (filename) | 2728 (filename) |
4507 Qadd_name_to_file = intern ("add-name-to-file"); | 4534 Qadd_name_to_file = intern ("add-name-to-file"); |
4508 Qmake_symbolic_link = intern ("make-symbolic-link"); | 4535 Qmake_symbolic_link = intern ("make-symbolic-link"); |
4509 Qfile_exists_p = intern ("file-exists-p"); | 4536 Qfile_exists_p = intern ("file-exists-p"); |
4510 Qfile_executable_p = intern ("file-executable-p"); | 4537 Qfile_executable_p = intern ("file-executable-p"); |
4511 Qfile_readable_p = intern ("file-readable-p"); | 4538 Qfile_readable_p = intern ("file-readable-p"); |
4539 Qfile_writable_p = intern ("file-writable-p"); | |
4512 Qfile_symlink_p = intern ("file-symlink-p"); | 4540 Qfile_symlink_p = intern ("file-symlink-p"); |
4513 Qfile_writable_p = intern ("file-writable-p"); | 4541 Qaccess_file = intern ("access-file"); |
4514 Qfile_directory_p = intern ("file-directory-p"); | 4542 Qfile_directory_p = intern ("file-directory-p"); |
4515 Qfile_regular_p = intern ("file-regular-p"); | 4543 Qfile_regular_p = intern ("file-regular-p"); |
4516 Qfile_accessible_directory_p = intern ("file-accessible-directory-p"); | 4544 Qfile_accessible_directory_p = intern ("file-accessible-directory-p"); |
4517 Qfile_modes = intern ("file-modes"); | 4545 Qfile_modes = intern ("file-modes"); |
4518 Qset_file_modes = intern ("set-file-modes"); | 4546 Qset_file_modes = intern ("set-file-modes"); |
4537 staticpro (&Qadd_name_to_file); | 4565 staticpro (&Qadd_name_to_file); |
4538 staticpro (&Qmake_symbolic_link); | 4566 staticpro (&Qmake_symbolic_link); |
4539 staticpro (&Qfile_exists_p); | 4567 staticpro (&Qfile_exists_p); |
4540 staticpro (&Qfile_executable_p); | 4568 staticpro (&Qfile_executable_p); |
4541 staticpro (&Qfile_readable_p); | 4569 staticpro (&Qfile_readable_p); |
4570 staticpro (&Qfile_writable_p); | |
4571 staticpro (&Qaccess_file); | |
4542 staticpro (&Qfile_symlink_p); | 4572 staticpro (&Qfile_symlink_p); |
4543 staticpro (&Qfile_writable_p); | |
4544 staticpro (&Qfile_directory_p); | 4573 staticpro (&Qfile_directory_p); |
4545 staticpro (&Qfile_regular_p); | 4574 staticpro (&Qfile_regular_p); |
4546 staticpro (&Qfile_accessible_directory_p); | 4575 staticpro (&Qfile_accessible_directory_p); |
4547 staticpro (&Qfile_modes); | 4576 staticpro (&Qfile_modes); |
4548 staticpro (&Qset_file_modes); | 4577 staticpro (&Qset_file_modes); |
4693 defsubr (&Sfile_name_absolute_p); | 4722 defsubr (&Sfile_name_absolute_p); |
4694 defsubr (&Sfile_exists_p); | 4723 defsubr (&Sfile_exists_p); |
4695 defsubr (&Sfile_executable_p); | 4724 defsubr (&Sfile_executable_p); |
4696 defsubr (&Sfile_readable_p); | 4725 defsubr (&Sfile_readable_p); |
4697 defsubr (&Sfile_writable_p); | 4726 defsubr (&Sfile_writable_p); |
4727 defsubr (&Saccess_file); | |
4698 defsubr (&Sfile_symlink_p); | 4728 defsubr (&Sfile_symlink_p); |
4699 defsubr (&Sfile_directory_p); | 4729 defsubr (&Sfile_directory_p); |
4700 defsubr (&Sfile_accessible_directory_p); | 4730 defsubr (&Sfile_accessible_directory_p); |
4701 defsubr (&Sfile_regular_p); | 4731 defsubr (&Sfile_regular_p); |
4702 defsubr (&Sfile_modes); | 4732 defsubr (&Sfile_modes); |