emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r110295: file-attributes has a new op


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110295: file-attributes has a new optional arg FOLLOW-SYMLINKS.
Date: Sun, 30 Sep 2012 14:12:04 -0700
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110295
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Sun 2012-09-30 14:12:04 -0700
message:
  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.
modified:
  doc/lispref/ChangeLog
  doc/lispref/files.texi
  etc/ChangeLog
  etc/NEWS
  lisp/ChangeLog
  lisp/files.el
  lisp/time.el
  src/ChangeLog
  src/dired.c
  src/lisp.h
  src/sysdep.c
=== modified file 'doc/lispref/ChangeLog'
--- a/doc/lispref/ChangeLog     2012-09-30 09:18:38 +0000
+++ b/doc/lispref/ChangeLog     2012-09-30 21:12:04 +0000
@@ -1,3 +1,9 @@
+2012-09-30  Paul Eggert  <address@hidden>
+
+       file-attributes has a new optional arg FOLLOW-SYMLINKS.
+       * files.texi (File Attributes): Describe it.
+       (Magic File Names): Use it.
+
 2012-09-30  Chong Yidong  <address@hidden>
 
        * commands.texi (Click Events): Define "mouse position list".

=== modified file 'doc/lispref/files.texi'
--- a/doc/lispref/files.texi    2012-09-28 16:02:31 +0000
+++ b/doc/lispref/files.texi    2012-09-30 21:12:04 +0000
@@ -1187,7 +1187,7 @@
 @end example
 @end defun
 
address@hidden file-attributes filename &optional id-format
address@hidden file-attributes filename &optional id-format follow-symlinks
 @anchor{Definition of file-attributes}
 This function returns a list of attributes of file @var{filename}.  If
 the specified file cannot be opened, it returns @code{nil}.
@@ -1197,6 +1197,9 @@
 the default, but we plan to change that, so you should specify a
 address@hidden value for @var{id-format} if you use the returned
 @acronym{UID} or @acronym{GID}.
+The optional parameter @var{follow-symlinks} says whether to follow
address@hidden if it is a symbolic link; if @code{t}, symbolic links
+are followed and if @code{nil} they are not.
 
 The elements of the list, in order, are:
 
@@ -2961,8 +2964,7 @@
   (let ((remote-file-name-inhibit-cache
          (- display-time-interval 5)))
     (and (file-exists-p file)
-         (< 0 (nth 7 (file-attributes
-                       (file-chase-links file)))))))
+         (< 0 (nth 7 (file-attributes file nil t))))))
 @end example
 @end defopt
 

=== modified file 'etc/ChangeLog'
--- a/etc/ChangeLog     2012-09-30 13:43:47 +0000
+++ b/etc/ChangeLog     2012-09-30 21:12:04 +0000
@@ -1,3 +1,8 @@
+2012-09-30  Paul Eggert  <address@hidden>
+
+       file-attributes has a new optional arg FOLLOW-SYMLINKS.
+       * NEWS: Document the change.
+
 2012-09-30  Jan Djärv  <address@hidden>
 
        * NEWS: The NS port supports fullscreen.

=== modified file 'etc/NEWS'
--- a/etc/NEWS  2012-09-30 13:43:47 +0000
+++ b/etc/NEWS  2012-09-30 21:12:04 +0000
@@ -807,6 +807,11 @@
 accessed via the new timer--psecs accessor.
 
 +++
+** file-attributes has a new optional argument FOLLOW-SYMLINKS
+that says whether to follow symbolic links.  The default, as before,
+is to not follow symlinks.
+
++++
 ** Floating point functions now always return special values like NaN,
 instead of signaling errors, if given invalid args, e.g. (log -1.0).
 Previously, they returned NaNs on some platforms but signaled errors

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-09-30 20:30:13 +0000
+++ b/lisp/ChangeLog    2012-09-30 21:12:04 +0000
@@ -1,3 +1,11 @@
+2012-09-30  Paul Eggert  <address@hidden>
+
+       file-attributes has a new optional arg FOLLOW-SYMLINKS.
+       * files.el (remote-file-name-inhibit-cache):
+       * time.el (display-time-file-nonempty-p): Use it.
+       * files.el (after-find-file): Don't chase links before calling
+       file-exists-p, as file-exists-p already does the right thing.
+
 2012-09-30  Ralf Angeli  <address@hidden>
 
        Merge from standalone RefTeX repository.

=== modified file 'lisp/files.el'
--- a/lisp/files.el     2012-09-25 04:13:02 +0000
+++ b/lisp/files.el     2012-09-30 21:12:04 +0000
@@ -1014,7 +1014,7 @@
   (defun display-time-file-nonempty-p (file)
     (let ((remote-file-name-inhibit-cache (- display-time-interval 5)))
       (and (file-exists-p file)
-           (< 0 (nth 7 (file-attributes (file-chase-links file)))))))"
+           (< 0 (nth 7 (file-attributes file nil t))))))"
   :group 'files
   :version "24.1"
   :type `(choice
@@ -2082,8 +2082,7 @@
             ((and error (file-attributes buffer-file-name))
              (setq buffer-read-only t)
              (if (and (file-symlink-p buffer-file-name)
-                      (not (file-exists-p
-                            (file-chase-links buffer-file-name))))
+                      (not (file-exists-p buffer-file-name)))
                  "Symbolic link that points to nonexistent file"
                "File exists, but cannot be read"))
             ((not buffer-read-only)

=== modified file 'lisp/time.el'
--- a/lisp/time.el      2012-09-13 06:09:45 +0000
+++ b/lisp/time.el      2012-09-30 21:12:04 +0000
@@ -485,7 +485,7 @@
 (defun display-time-file-nonempty-p (file)
   (let ((remote-file-name-inhibit-cache (- display-time-interval 5)))
     (and (file-exists-p file)
-        (< 0 (nth 7 (file-attributes (file-chase-links file)))))))
+        (< 0 (nth 7 (file-attributes file nil t))))))
 
 ;;;###autoload
 (define-minor-mode display-time-mode

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-09-30 20:06:20 +0000
+++ b/src/ChangeLog     2012-09-30 21:12:04 +0000
@@ -1,3 +1,9 @@
+2012-09-30  Paul Eggert  <address@hidden>
+
+       file-attributes has a new optional arg FOLLOW-SYMLINKS.
+       * dired.c (directory_files_internal, Ffile_attributes):
+       New arg follow_symlinks.  All uses changed.
+
 2012-09-30  Stefan Monnier  <address@hidden>
 
        * .gdbinit (xbacktrace): Adjust to recent "struct backtrace" change.

=== modified file 'src/dired.c'
--- a/src/dired.c       2012-09-23 08:44:20 +0000
+++ b/src/dired.c       2012-09-30 21:12:04 +0000
@@ -110,12 +110,13 @@
 /* Function shared by Fdirectory_files and Fdirectory_files_and_attributes.
    If not ATTRS, return a list of directory filenames;
    if ATTRS, return a list of directory filenames and their attributes.
-   In the latter case, ID_FORMAT is passed to Ffile_attributes.  */
+   In the latter case, ID_FORMAT and FOLLOW_SYMLINKS are passed to
+   Ffile_attributes.  */
 
 Lisp_Object
 directory_files_internal (Lisp_Object directory, Lisp_Object full,
                          Lisp_Object match, Lisp_Object nosort, bool attrs,
-                         Lisp_Object id_format)
+                         Lisp_Object id_format, Lisp_Object follow_symlinks)
 {
   DIR *d;
   ptrdiff_t directory_nbytes;
@@ -297,7 +298,8 @@
 
                  /* Both Fexpand_file_name and Ffile_attributes can GC.  */
                  decoded_fullname = Fexpand_file_name (name, directory);
-                 fileattrs = Ffile_attributes (decoded_fullname, id_format);
+                 fileattrs = Ffile_attributes (decoded_fullname, id_format,
+                                               follow_symlinks);
 
                  list = Fcons (Fcons (finalname, fileattrs), list);
                  UNGCPRO;
@@ -350,7 +352,8 @@
     return call5 (handler, Qdirectory_files, directory,
                   full, match, nosort);
 
-  return directory_files_internal (directory, full, match, nosort, 0, Qnil);
+  return directory_files_internal (directory, full, match, nosort, 0,
+                                  Qnil, Qnil);
 }
 
 DEFUN ("directory-files-and-attributes", Fdirectory_files_and_attributes,
@@ -378,7 +381,8 @@
     return call6 (handler, Qdirectory_files_and_attributes,
                   directory, full, match, nosort, id_format);
 
-  return directory_files_internal (directory, full, match, nosort, 1, 
id_format);
+  return directory_files_internal (directory, full, match, nosort, 1,
+                                  id_format, Qnil);
 }
 
 
@@ -875,7 +879,7 @@
 #endif
 }
 
-DEFUN ("file-attributes", Ffile_attributes, Sfile_attributes, 1, 2, 0,
+DEFUN ("file-attributes", Ffile_attributes, Sfile_attributes, 1, 3, 0,
        doc: /* Return a list of attributes of file FILENAME.
 Value is nil if specified file cannot be opened.
 
@@ -884,6 +888,9 @@
 default, but we plan to change that, so you should specify a non-nil value
 for ID-FORMAT if you use the returned uid or gid.
 
+Optional argument FOLLOW-SYMLINKS says whether to follow symbolic
+links.  If t, they are followed; if nil, they are not.
+
 Elements of the attribute list are:
  0. t for directory, string (name linked to) for symbolic link, or nil.
  1. Number of links to file.
@@ -917,7 +924,7 @@
 
 On some FAT-based filesystems, only the date of last access is recorded,
 so last access time will always be midnight of that day.  */)
-  (Lisp_Object filename, Lisp_Object id_format)
+  (Lisp_Object filename, Lisp_Object id_format, Lisp_Object follow_symlinks)
 {
   Lisp_Object values[12];
   Lisp_Object encoded;
@@ -953,7 +960,10 @@
   encoded = ENCODE_FILE (filename);
   UNGCPRO;
 
-  if (lstat (SSDATA (encoded), &s) < 0)
+  if ((!NILP (follow_symlinks)
+       ? stat (SSDATA (encoded), &s)
+       : lstat (SSDATA (encoded), &s))
+      != 0)
     return Qnil;
 
   values[0] = (S_ISLNK (s.st_mode) ? Ffile_symlink_p (filename)

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2012-09-29 02:02:34 +0000
+++ b/src/lisp.h        2012-09-30 21:12:04 +0000
@@ -3474,7 +3474,7 @@
 extern void syms_of_dired (void);
 extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object,
                                              Lisp_Object, Lisp_Object,
-                                             bool, Lisp_Object);
+                                             bool, Lisp_Object, Lisp_Object);
 
 /* Defined in term.c.  */
 extern int *char_ins_del_vector;

=== modified file 'src/sysdep.c'
--- a/src/sysdep.c      2012-09-30 06:19:33 +0000
+++ b/src/sysdep.c      2012-09-30 21:12:04 +0000
@@ -2529,7 +2529,8 @@
      process.  */
   procdir = build_string ("/proc");
   match = build_string ("[0-9]+");
-  proclist = directory_files_internal (procdir, Qnil, match, Qt, 0, Qnil);
+  proclist = directory_files_internal (procdir, Qnil, match, Qt, 0,
+                                      Qnil, Qnil);
 
   /* `proclist' gives process IDs as strings.  Destructively convert
      each string into a number.  */


reply via email to

[Prev in Thread] Current Thread [Next in Thread]