*** empty log message ***
[gnus] / lisp / nnheader.el
index a43047c..ab49c59 100644 (file)
@@ -450,20 +450,22 @@ on your system, you could say something like:
       file 
     ;; We translate -- but only the file name.  We leave the directory
     ;; alone.
-    (let* ((new (if (string-match "/[^/]+\\'" file)
-                   ;; This is needed on NT's and stuff.
-                   (substring file (1+ (match-beginning 0)))
-                 ;; Fall back on this.
-                 (file-name-nondirectory file)))
-          (len (length new))
-          (i 0)
-          trans)
+    (let* ((i 0)
+          trans leaf path len)
+      (if (string-match "/[^/]+\\'" file)
+         ;; This is needed on NT's and stuff.
+         (setq leaf (substring file (1+ (match-beginning 0)))
+               path (substring file 0 (1+ (match-beginning 0))))
+       ;; Fall back on this.
+       (setq leaf (file-name-nondirectory file)
+             path (file-name-directory file)))
+      (setq len (length leaf))
       (while (< i len)
-       (when (setq trans (cdr (assq (aref new i)
+       (when (setq trans (cdr (assq (aref leaf i)
                                     nnheader-file-name-translation-alist)))
-         (aset new i trans))
+         (aset leaf i trans))
        (incf i))
-      (concat (file-name-directory file) new))))
+      (concat path leaf))))
 
 (defun nnheader-report (backend &rest args)
   "Report an error from the BACKEND.
@@ -568,6 +570,40 @@ without formatting."
     (while (re-search-forward "\r$" nil t)
       (delete-backward-char 1))))
 
+(defun nnheader-file-size (file)
+  "Return the file size of FILE or 0."
+  (or (nth 7 (file-attributes file)) 0))
+
+(defun nnheader-find-etc-directory (package)
+  "Go through the path and find the \".../etc/PACKAGE\" directory."
+  (let ((path load-path)
+       dir result)
+    ;; We try to find the dir by looking at the load path,
+    ;; stripping away the last component and adding "etc/".
+    (while path
+      (if (and (car path)
+              (file-exists-p
+               (setq dir (concat
+                          (file-name-directory
+                           (directory-file-name (car path)))
+                          "etc/" package "/")))
+              (file-directory-p dir))
+         (setq result dir
+               path nil)
+       (setq path (cdr path))))
+    result))
+
+(defvar ange-ftp-path-format)
+(defvar efs-path-regexp)
+(defun nnheader-re-read-dir (path)
+  "Re-read directory PATH if PATH is on a remote system."
+    (if (and (fboundp 'efs-re-read-dir) (boundp 'efs-path-regexp))
+       (when (string-match efs-path-regexp path)
+         (efs-re-read-dir path))
+     (if (and (fboundp 'ange-ftp-re-read-dir) (boundp 'ange-ftp-path-format))
+      (when (string-match (car ange-ftp-path-format) path)
+       (ange-ftp-re-read-dir path)))))
+
 (fset 'nnheader-run-at-time 'run-at-time)
 (fset 'nnheader-cancel-timer 'cancel-timer)
 (fset 'nnheader-find-file-noselect 'find-file-noselect)