aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2012-09-30 14:12:04 -0700
committerPaul Eggert2012-09-30 14:12:04 -0700
commite7a2937b11bffc9ac24936e9f46201ce2abf38cc (patch)
tree93dcf60d3f9136ef291a68e76d793a5feb50f3d6 /src
parentb9ab1b1f1c8f85fb624b9f170f4adf7f764d248b (diff)
downloademacs-e7a2937b11bffc9ac24936e9f46201ce2abf38cc.tar.gz
emacs-e7a2937b11bffc9ac24936e9f46201ce2abf38cc.zip
file-attributes has a new optional arg FOLLOW-SYMLINKS.
* doc/lispref/files.texi (File Attributes): Describe it. (Magic File Names): Use it. * etc/NEWS: Document the change. * lisp/files.el (remote-file-name-inhibit-cache): * lisp/time.el (display-time-file-nonempty-p): Use it. * lisp/files.el (after-find-file): Don't chase links before calling file-exists-p, as file-exists-p already does the right thing. * src/dired.c (directory_files_internal, Ffile_attributes): New arg follow_symlinks. All uses changed.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/dired.c26
-rw-r--r--src/lisp.h2
-rw-r--r--src/sysdep.c3
4 files changed, 27 insertions, 10 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1d3d1f7f4e2..257333a3f98 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12012-09-30 Paul Eggert <eggert@cs.ucla.edu>
2
3 file-attributes has a new optional arg FOLLOW-SYMLINKS.
4 * dired.c (directory_files_internal, Ffile_attributes):
5 New arg follow_symlinks. All uses changed.
6
12012-09-30 Stefan Monnier <monnier@iro.umontreal.ca> 72012-09-30 Stefan Monnier <monnier@iro.umontreal.ca>
2 8
3 * .gdbinit (xbacktrace): Adjust to recent "struct backtrace" change. 9 * .gdbinit (xbacktrace): Adjust to recent "struct backtrace" change.
diff --git a/src/dired.c b/src/dired.c
index 4986f845101..84a172deb58 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -110,12 +110,13 @@ directory_files_internal_unwind (Lisp_Object dh)
110/* Function shared by Fdirectory_files and Fdirectory_files_and_attributes. 110/* Function shared by Fdirectory_files and Fdirectory_files_and_attributes.
111 If not ATTRS, return a list of directory filenames; 111 If not ATTRS, return a list of directory filenames;
112 if ATTRS, return a list of directory filenames and their attributes. 112 if ATTRS, return a list of directory filenames and their attributes.
113 In the latter case, ID_FORMAT is passed to Ffile_attributes. */ 113 In the latter case, ID_FORMAT and FOLLOW_SYMLINKS are passed to
114 Ffile_attributes. */
114 115
115Lisp_Object 116Lisp_Object
116directory_files_internal (Lisp_Object directory, Lisp_Object full, 117directory_files_internal (Lisp_Object directory, Lisp_Object full,
117 Lisp_Object match, Lisp_Object nosort, bool attrs, 118 Lisp_Object match, Lisp_Object nosort, bool attrs,
118 Lisp_Object id_format) 119 Lisp_Object id_format, Lisp_Object follow_symlinks)
119{ 120{
120 DIR *d; 121 DIR *d;
121 ptrdiff_t directory_nbytes; 122 ptrdiff_t directory_nbytes;
@@ -297,7 +298,8 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
297 298
298 /* Both Fexpand_file_name and Ffile_attributes can GC. */ 299 /* Both Fexpand_file_name and Ffile_attributes can GC. */
299 decoded_fullname = Fexpand_file_name (name, directory); 300 decoded_fullname = Fexpand_file_name (name, directory);
300 fileattrs = Ffile_attributes (decoded_fullname, id_format); 301 fileattrs = Ffile_attributes (decoded_fullname, id_format,
302 follow_symlinks);
301 303
302 list = Fcons (Fcons (finalname, fileattrs), list); 304 list = Fcons (Fcons (finalname, fileattrs), list);
303 UNGCPRO; 305 UNGCPRO;
@@ -350,7 +352,8 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
350 return call5 (handler, Qdirectory_files, directory, 352 return call5 (handler, Qdirectory_files, directory,
351 full, match, nosort); 353 full, match, nosort);
352 354
353 return directory_files_internal (directory, full, match, nosort, 0, Qnil); 355 return directory_files_internal (directory, full, match, nosort, 0,
356 Qnil, Qnil);
354} 357}
355 358
356DEFUN ("directory-files-and-attributes", Fdirectory_files_and_attributes, 359DEFUN ("directory-files-and-attributes", Fdirectory_files_and_attributes,
@@ -378,7 +381,8 @@ which see. */)
378 return call6 (handler, Qdirectory_files_and_attributes, 381 return call6 (handler, Qdirectory_files_and_attributes,
379 directory, full, match, nosort, id_format); 382 directory, full, match, nosort, id_format);
380 383
381 return directory_files_internal (directory, full, match, nosort, 1, id_format); 384 return directory_files_internal (directory, full, match, nosort, 1,
385 id_format, Qnil);
382} 386}
383 387
384 388
@@ -875,7 +879,7 @@ stat_gname (struct stat *st)
875#endif 879#endif
876} 880}
877 881
878DEFUN ("file-attributes", Ffile_attributes, Sfile_attributes, 1, 2, 0, 882DEFUN ("file-attributes", Ffile_attributes, Sfile_attributes, 1, 3, 0,
879 doc: /* Return a list of attributes of file FILENAME. 883 doc: /* Return a list of attributes of file FILENAME.
880Value is nil if specified file cannot be opened. 884Value is nil if specified file cannot be opened.
881 885
@@ -884,6 +888,9 @@ below) - valid values are 'string and 'integer. The latter is the
884default, but we plan to change that, so you should specify a non-nil value 888default, but we plan to change that, so you should specify a non-nil value
885for ID-FORMAT if you use the returned uid or gid. 889for ID-FORMAT if you use the returned uid or gid.
886 890
891Optional argument FOLLOW-SYMLINKS says whether to follow symbolic
892links. If t, they are followed; if nil, they are not.
893
887Elements of the attribute list are: 894Elements of the attribute list are:
888 0. t for directory, string (name linked to) for symbolic link, or nil. 895 0. t for directory, string (name linked to) for symbolic link, or nil.
889 1. Number of links to file. 896 1. Number of links to file.
@@ -917,7 +924,7 @@ which see.
917 924
918On some FAT-based filesystems, only the date of last access is recorded, 925On some FAT-based filesystems, only the date of last access is recorded,
919so last access time will always be midnight of that day. */) 926so last access time will always be midnight of that day. */)
920 (Lisp_Object filename, Lisp_Object id_format) 927 (Lisp_Object filename, Lisp_Object id_format, Lisp_Object follow_symlinks)
921{ 928{
922 Lisp_Object values[12]; 929 Lisp_Object values[12];
923 Lisp_Object encoded; 930 Lisp_Object encoded;
@@ -953,7 +960,10 @@ so last access time will always be midnight of that day. */)
953 encoded = ENCODE_FILE (filename); 960 encoded = ENCODE_FILE (filename);
954 UNGCPRO; 961 UNGCPRO;
955 962
956 if (lstat (SSDATA (encoded), &s) < 0) 963 if ((!NILP (follow_symlinks)
964 ? stat (SSDATA (encoded), &s)
965 : lstat (SSDATA (encoded), &s))
966 != 0)
957 return Qnil; 967 return Qnil;
958 968
959 values[0] = (S_ISLNK (s.st_mode) ? Ffile_symlink_p (filename) 969 values[0] = (S_ISLNK (s.st_mode) ? Ffile_symlink_p (filename)
diff --git a/src/lisp.h b/src/lisp.h
index c3cabe0af29..e182d3bc14b 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3474,7 +3474,7 @@ extern void syms_of_ccl (void);
3474extern void syms_of_dired (void); 3474extern void syms_of_dired (void);
3475extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object, 3475extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object,
3476 Lisp_Object, Lisp_Object, 3476 Lisp_Object, Lisp_Object,
3477 bool, Lisp_Object); 3477 bool, Lisp_Object, Lisp_Object);
3478 3478
3479/* Defined in term.c. */ 3479/* Defined in term.c. */
3480extern int *char_ins_del_vector; 3480extern int *char_ins_del_vector;
diff --git a/src/sysdep.c b/src/sysdep.c
index b7141011d05..b7ddafdcea7 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -2529,7 +2529,8 @@ list_system_processes (void)
2529 process. */ 2529 process. */
2530 procdir = build_string ("/proc"); 2530 procdir = build_string ("/proc");
2531 match = build_string ("[0-9]+"); 2531 match = build_string ("[0-9]+");
2532 proclist = directory_files_internal (procdir, Qnil, match, Qt, 0, Qnil); 2532 proclist = directory_files_internal (procdir, Qnil, match, Qt, 0,
2533 Qnil, Qnil);
2533 2534
2534 /* `proclist' gives process IDs as strings. Destructively convert 2535 /* `proclist' gives process IDs as strings. Destructively convert
2535 each string into a number. */ 2536 each string into a number. */